public function getContent() { global $sql; // Strona zabezpieczona wykonuje dwa niepotrzebne zapytania, mimo, że tekst sie nie wyświetla, należy po pierwszym zapytaniu wykonać fetch_assoc $page = $sql->query(' SELECT * FROM ' . DB_PREFIX . 'subpages WHERE id = ' . $this->id)->fetch(); // Page does not exist if (!$page) { return not_found('Page you have been loking for does not exists.'); } else { if ($page['permit'] == 0) { return no_access(); } else { if (!LOGGED && $page['type'] == 2) { return no_access(array('Wybrana treść jest dostępna tylko dla zalogowanych osób.', t('REGISTER'))); } else { Kio::addTitle($page['title']); Kio::addBreadcrumb($page['title'], $page['id'] . '/' . clean_url($page['title'])); // $this->subcodename = $page['number']; Kio::addHead($page['head']); if ($page['description']) { Kio::setDescription($page['description']); } if ($page['keywords']) { Kio::setKeywords($page['keywords']); } return eval('?>' . $page['content']); } } } }
private function getEntries() { global $sql; $pager_url = 'news'; $category_id = 0; if (u1 == 'category') { $category_id = (int) u2; } $total = Kio::getStat('entries', 'news'); if ($category_id) { $category = $sql->setCache('news_categories_' . $category_id)->query(' SELECT id, name, description, entries FROM ' . DB_PREFIX . 'news_categories WHERE id = ' . $category_id)->fetch(PDO::FETCH_ASSOC); if ($category) { $total = $category['entries']; if ($category['description']) { Kio::setDescription($category['name'] . ' - ' . $category['description']); } Kio::addTitle($category['name']); Kio::addBreadcrumb($category['name'], 'news/category/' . $category_id . '/' . clean_url($category['name'])); $pager_url = 'news/category/' . $category_id . '/' . clean_url($category['name']); } else { return not_found(t('Selected category does not exists.'), array(t('Category was moved or deleted.'), t('Entered URL is invalid.'))); } } if (!empty($category) || empty($category)) { $this->subcodename = 'entries'; $pager = new Pager($pager_url, $total, Kio::getConfig('limit', 'news')); $stmt = $sql->setCache('news_' . $category_id . '_' . $pager->current)->query(' SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.* FROM ' . DB_PREFIX . 'news n LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = n.author_id LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id WHERE ' . ($category_id ? 'c.id = ' . $category_id . ' AND ' : '') . (LOGGED ? 'n.publication > 0' : 'n.publication = 1') . ' AND n.added < ' . TIMESTAMP . ' ORDER BY ' . Kio::getConfig('order_by', 'news') . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $stmt->fetch()) { if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']); } $row['url_title'] = ($row['c_name'] ? clean_url($row['c_name']) . '/' : '') . clean_url($row['title']); $row['content'] = parse($row['content'], Kio::getConfig('parsers', 'news')); $entries[] = $row; } try { $tpl = new PHPTAL('modules/news/news.tpl.html'); $tpl->entries = $entries; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } }
public function getContent() { global $sql; // $kio->disableRegion('left'); if (u1 || LOGGED) { // TODO: Zamiast zapytania dla własnego konta dać User::toArray() $profile = $sql->query(' SELECT u.* FROM ' . DB_PREFIX . 'users u WHERE u.id = ' . (ctype_digit(u1) ? u1 : UID))->fetch(); } if ($profile) { Kio::addTitle(t('Users')); Kio::addBreadcrumb(t('Users'), 'users'); Kio::addTitle($profile['nickname']); Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1 . '/' . clean_url($profile['nickname'])); Kio::setDescription(t('%nickname's profile', array('%nickname' => $profile['nickname'])) . ($profile['title'] ? ' - ' . $profile['title'] : '')); Kio::addTabs(array(t('Edit profile') => 'edit_profile/' . u1)); if ($profile['birthdate']) { $profile['bd'] = $profile['birthdate'] ? explode('-', $profile['birthdate']) : ''; // DD Month YYYY (Remaining days to next birthday) $profile['birthdate'] = $profile['bd'][2] . ' ' . Kio::$months[$profile['bd'][1]] . ' ' . $profile['bd'][0] . ' (' . day_diff(mktime(0, 0, 0, $profile['bd'][1], $profile['bd'][2] + 1, date('y')), t('%d days remaining')) . ')'; $profile['age'] = get_age($profile['bd'][2], $profile['bd'][1], $profile['bd'][0]); if (Plugin::exists('zodiac')) { require_once ROOT . 'plugins/zodiac/zodiac.plugin.php'; $profile['zodiac'] = Zodiac::get($profile['bd'][2], $profile['bd'][1]); } } if ($profile['http_agent'] && Plugin::exists('user_agent')) { require_once ROOT . 'plugins/user_agent/user_agent.plugin.php'; $profile['os'] = User_Agent::getOS($profile['http_agent']); $profile['browser'] = User_Agent::getBrowser($profile['http_agent']); } $group = Kio::getGroup($profile['group_id']); $profile['group'] = $group['name'] ? $group['inline'] ? sprintf($group['inline'], $group['name']) : $group['name'] : ''; if ($profile['gender']) { $profile['gender'] = $profile['gender'] == 1 ? t('Male') : t('Female'); } try { // TODO: Zrobić modyfikator dla funkcji o wielu parametrach (teraz jest tylko jeden możliwy) $tpl = new PHPTAL('modules/profile/profile.tpl.html'); $tpl->profile = $profile; return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } else { return not_found(t('Selected user doesn't exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.'))); } }
private function getImage() { global $sql, $plug; $image = $sql->getCache('gallery_image_' . u2); if (!$image) { $cache = false; $image = $sql->query(' SELECT a.id AS a_id, a.name a_name, a.description a_description, a.permit, a.images, i.*, u.nickname, u.group_id FROM ' . DB_PREFIX . 'gallery_images i LEFT JOIN ' . DB_PREFIX . 'gallery_albums a ON a.id = i.album_id LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = i.author_id WHERE i.id = ' . u2)->fetch(); } else { $cache = true; } if ($image) { Kio::addTitle($image['a_name']); Kio::addBreadcrumb($image['a_name'], 'gallery/album/' . $image['a_id'] . '/' . clean_url($image['a_name'])); Kio::addTitle($image['name']); Kio::addBreadcrumb($image['name'], 'gallery/image/' . $image['id'] . '/' . clean_url($image['name'])); $this->subcodename = 'image'; if (!$cache) { $image['counter'] = 0; $image['thumbs'] = array(); $query = $sql->query(' SELECT * FROM ' . DB_PREFIX . 'gallery_images WHERE album_id = ' . (int) $image['album_id']); while ($row = $query->fetch()) { $image['counter']++; $y[] = $row['id'] . '/' . clean_url($row['name']); if ($row['id'] == $image['id']) { $image['current'] = $image['counter']; } $image['thumbs'][] = $row; } if ($image['author_id']) { $image['author'] = User::format($image['author_id'], $image['nickname'], $image['group_id']); } // TODO: http://www.pixastic.com/lib/ $image['src'] = 'modules/gallery/images/' . $image['id'] . '.' . $image['file_extension']; //list($image['width'], $image['height']) = getimagesize(ROOT.$image['src']); $image['prev'] = $y[$image['current'] - 2]; $image['next'] = $y[$image['current']]; $sql->putCacheContent('gallery_image_' . u2, $image); } if ($image['description']) { Kio::setDescription($image['name'] . ' - ' . $image['description']); } // http://localhost/~kiocms/?images/gallery/15/5-5-0-0-0-0-0-0-0-0-0/biba.jpg try { $tpl = new PHPTAL('modules/gallery/image.tpl.html'); $tpl->image = $image; $tpl->thumbs = $image['thumbs']; $tpl->comments = ''; $tpl->comments = $plug->comments($image['id'], 'gallery_images', $image['comments'], 'gallery/image/' . $image['id'] . '/' . clean_url($image['name'])); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } else { return not_found(sprintf('Zdjęcie o numerze <strong>%s</strong> nie istnieje', u2), array('Zdjęcie zostało usunięte z bazy danych', 'Wprowadzony adres jest nieprawidłowy')); } }
define('TODAY', date('Y-m-d')); define('YESTERDAY', date('Y-m-d', TIMESTAMP - 86400)); define('TOMMOROW', date('Y-m-d', TIMESTAMP + 86400)); require_once ROOT . 'system/functions.php'; Kio::startTimer(); require_once ROOT . 'config.php'; error_reporting(ERRORS); if (!INSTALLED) { redirect(ROOT . 'install.php'); } require_once ROOT . 'system/' . DB_TYPE . '.php'; Kio::loadConfig(); Kio::loadStats(); Kio::loadGroups(); Kio::addTitle(Kio::getConfig('title')); Kio::setDescription(Kio::getConfig('description')); Kio::setKeywords(Kio::getConfig('keywords')); Kio::addHead(Kio::getConfig('header')); $kio->show_blocks = true; $kio->blocks = Kio::getConfig('blocks'); $kio->columns = Kio::getConfig('columns'); $kio->functions = array('set_magic_quotes_runtime', 'ini_set', 'date_default_timezone_set', 'mb_strlen'); $kio->functions = array_map('function_exists', array_combine($kio->functions, $kio->functions)); // Za spacje należy użyć \s, np. tanie\skomputery $kio->spam_words = str_replace(array(',', ' ', '#'), array('|', '', ''), Kio::getConfig('spam_words')); // Characters to replace $kio->chars = unserialize(Kio::getConfig('chars')) + array(' ' => '_', '\' => '', '"' => '', ''' => '', '`' => '', '"' => '', '>' => '', '<' => '', '&' => ''); // Check timezone_identifiers_list() $kio->bbcode = (include ROOT . 'system/parser/bbcode/' . (Kio::getConfig('bbcode_parser') ? Kio::getConfig('bbcode_parser') . '.php' : 'index.php')); $kio->emoticons = (include ROOT . 'system/parser/emoticons/' . (Kio::getConfig('emoticons_parser') ? Kio::getConfig('emoticons_parser') . '.php' : 'index.php')); $kio->censure = (include ROOT . 'system/parser/censure/' . (Kio::getConfig('censure_parser') ? Kio::getConfig('censure_parser') . '.php' : 'index.php'));