public function __construct() { $this->name = t($this->name); Kio::addTitle($this->name); Kio::addBreadcrumb($this->name, $this->codename); $this->blocks = array('left' => array('user_panel', 'partners', 'news_categories', 'shoutbox')); }
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']); } } } }
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.'))); } }
function __construct() { Kio::addTitle(t('Contact')); Kio::addBreadcrumb(t('Contact'), 'contact'); $this->note = new Notifier(); }
public function __construct() { Kio::addTitle(t('Log in')); Kio::addBreadcrumb(t('Log in'), 'login'); }
function __construct() { Kio::addTitle(t('Guestbook')); Kio::addBreadcrumb(t('Guestbook'), 'guestbook'); $this->note = new Notifier(); }
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); } } }
private function accountActivation() { global $sql; Kio::addTitle(t('Account activation')); $guest = $sql->query(' SELECT id, nickname, blocked, auth_code FROM ' . DB_PREFIX . 'users WHERE id = ' . u2)->fetch(PDO::FETCH_ASSOC); if ($guest) { if ($guest['auth_code'] == u3 && $guest['blocked'] == 1) { return $this->note->success(array('Twoje konto zostało pomyślnie aktywowane.', 'Dziękujemy.'), false); } else { if ($guest['blocked'] == 0) { return $this->note->error(sprintf('Konto użytkownika <strong>%s</strong> jest już aktywne.', $guest['nickname'])); } else { return $this->note->error('Kod aktywacyjny jest <strong>nieprawidłowy</strong>.'); } } } else { return $this->note->error(sprintf('Konto numer <strong>%u</strong> nie istnieje.', u2)); } }
/** * * @global object $kio * @global object $module * @param string $message * @param array $causes [optional] * @param bool $notify [optional] */ function not_found($message, $causes = array(), $notify = true) { global $kio, $module; if (!$causes) { $causes = array(t('Content was moved or deleted.'), t('Entered URL is invalid.')); } Kio::addTitle(t('Page not found')); $module->codename = 'error'; $module->subcodename = 'not_found'; $note = new Notifier(); $note->error(t($message)); try { $tpl = new PHPTAL('system/not_found.html'); $tpl->causes = $causes; $tpl->note = $note; echo $tpl->execute(); } catch (Exception $e) { template_error(); } }
public function getContent() { global $sql; if (!LOGGED) { return no_access('By mieć dostęp do edycji profilu musisz się zalogować.'); } $note = new Notifier(); $err = new Error(); $edit = isset($_POST['edit']) ? true : false; $countries = (include 'lang/countries.php'); asort($countries); //Edit user by ID if (ctype_digit(u1)) { $profile = $sql->query(' SELECT u.* FROM ' . DB_PREFIX . 'users u WHERE u.id = ' . u1)->fetch(PDO::FETCH_ASSOC); if ($profile) { Kio::addTitle(t('Users')); Kio::addBreadcrumb(t('Users'), 'users'); Kio::addTitle($profile['nickname'] . ' - ' . t('Edit profile')); Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1); Kio::addBreadcrumb(t('Edit profile'), 'edit_profile/' . u1); $form = $profile; } else { return not_found(t('Selected user doesn't exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.'))); } } else { $profile = User::toArray(); Kio::addTitle(t('Edit profile')); Kio::addBreadcrumb(t('Edit profile'), 'edit_profile'); } $form = $profile; $form['password'] = ''; $form['password2'] = ''; $form['birthdate'] = explode('-', $profile['birthdate']); $form['newsletter'] = $profile['newsletter'] ? 1 : 0; $form['pm_notify'] = $profile['pm_notify'] ? 1 : 0; $form['hide_email'] = $profile['hide_email'] ? 1 : 0; if (!u1 || $profile) { // Edit profile if (!empty($edit)) { $form = array('nickname' => Kio::getConfig('allow_change_nick', 'edit_profile') ? filter($_POST['nickname'], 100) : User::$nickname, 'password' => filter($_POST['password'], 100), 'password2' => filter($_POST['password2'], 100), 'email' => strtolower(filter($_POST['email'], 100)), 'forename' => $_POST['forename'], 'surname' => $_POST['surname'], 'gender' => $_POST['gender'], 'locality' => $_POST['locality'], 'country' => !empty($countries[$_POST['country']]) ? $_POST['country'] : '', 'communicator' => $_POST['communicator'], 'website' => $_POST['website'], 'birthdate' => array_map('intval', (array) $_POST['birthdate']), 'newsletter' => isset($_POST['newsletter']) ? 1 : 0, 'pm_notify' => isset($_POST['pm_notify']) ? 1 : 0, 'hide_email' => isset($_POST['hide_email']) ? 1 : 0, 'avatar' => $_FILES['avatar']['error'] == 0 && !$_POST['delete_avatar'] ? $_FILES['avatar'] : array(), 'delete_avatar' => isset($_POST['delete_avatar']) ? 1 : 0, 'photo' => isset($_FILES['photo']) ? $_FILES['photo'] : null, 'delete_photo' => isset($_POST['delete_photo']) ? 1 : 0, 'title' => $_POST['title'], 'interests' => $_POST['interests'], 'signature' => $_POST['signature']); $allowed_types = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif'); // Nickname $err->setError('nickname_empty', t('ERROR_NICKNAME_EMPTY'))->condition(!$form['nickname']); $err->setError('nickname_exists', t('ERROR_NICKNAME_EXISTS'))->condition(Kio::getConfig('allow_change_nick', 'edit_profile') && $form['nickname'] && strtolower($form['nickname']) != strtolower($profile['nickname']) && is_registered($form['nickname'])); // Password $err->setError('password_differ', t('ERROR_PASSWORD_DIFFER'))->condition($form['password'] != $form['password2']); // E-mail $err->setError('email_empty', t('ERROR_EMAIL_EMPTY'))->condition(!$form['email']); if ($form['email']) { $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email'])); $err->setError('email_exists', t('ERROR_EMAIL_EXISTS'))->condition($form['email'] != $profile['email'] && is_email($form['email']) && is_registered($form['email'], 'email')); } // Birthdate $err->setError('birthdate_invalid', t('ERROR_BIRTHDATE'))->condition(array_sum($form['birthdate']) > 0 && !is_date('Y-n-j', $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2])); // Avatar if ($form['avatar']) { $err->avatar_invalid_type(t('ERROR_ava'))->condition(!in_array($form['avatar']['type'], array_keys($allowed_types))); $err->avatar_exceeded_max_size(t('ERROR_ava'))->condition(Kio::getConfig('avatar_size_max', 'edit_profile') && !$err->isError('avatar_invalid_type') && $form['avatar']['size'] > Kio::getConfig('avatar_size_max', 'edit_profile')); } // No errors if ($err->noErrors()) { if ($form['delete_avatar']) { unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar); } if ($form['avatar']) { move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT . 'images/avatars/' . $profile['id'] . '.' . $allowed_types[$form['avatar']['type']]); if ($allowed_types[$form['avatar']['type']] != User::$avatar) { unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar); } } $form['birthdate'] = array_sum($form['birthdate']) > 0 ? $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2] : ''; $sql->exec(' UPDATE ' . DB_PREFIX . 'users SET nickname = "' . (Kio::getConfig('allow_change_nick', 'edit_profile') ? $form['nickname'] : User::$nickname) . '", ' . ($form['password'] ? 'pass = "******",' : '') . ' email = "' . $form['email'] . '", forename = "' . $form['forename'] . '", surname = "' . $form['surname'] . '", gender = ' . ($form['gender'] == 1 || $form['gender'] == 2 ? (int) $form['gender'] : 0) . ', locality = "' . $form['locality'] . '", country = "' . $form['country'] . '", communicator = "' . $form['communicator'] . '", website = "' . $form['website'] . '", birthdate = "' . $form['birthdate'] . '", newsletter = ' . $form['newsletter'] . ', pm_notify = ' . $form['pm_notify'] . ', hide_email = ' . $form['hide_email'] . ', ' . ($form['avatar'] ? 'avatar = "' . $allowed_types[$form['avatar']['type']] . '",' : ($form['delete_avatar'] ? 'avatar = "",' : '')) . ' title = "' . $form['title'] . '", interests = "' . $form['interests'] . '", signature = "' . $form['signature'] . '" WHERE id = ' . $profile['id']); $note->success(t('Your profile was modified successfully.')); redirect(HREF . 'edit_profile'); } else { $note->error($err->toArray()); } } try { $tpl = new PHPTAL('modules/edit_profile/edit_profile.tpl.html'); $tpl->profile = $profile; $tpl->countries = $countries; $tpl->allow_change_nick = Kio::getConfig('allow_change_nick', 'edit_profile'); $tpl->form = $form; $tpl->err = $err->toArray(); $tpl->note = $note; return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } }
case 'redirect': define('MODULE', 'redirect'); ctype_digit(u1) && ($row = sql_fetch_assoc(sql_query('SELECT url FROM ' . DB_PREFIX . 'redirect WHERE id = ' . u1))) ? sql_query('UPDATE ' . DB_PREFIX . 'redirect SET clicks = clicks + 1 WHERE id = ' . u1) . redirect($row['url']) : redirect(LOCAL); break; // Load block as module // Load block as module case 'blocks': try { // Load block if (!Block::exists(u1)) { throw new Exception(t('Block dosn't exists')); } require_once ROOT . 'blocks/' . u1 . '/' . u1 . '.block.php'; $codename = u1; $module = new $codename(Block::getBlockData(u1), true); Kio::addTitle($module->name); Kio::addBreadcrumb($module->name, 'blocks/' . u1); echo $module->getContent(); define('MODULE', u1); } catch (Exception $e) { define('MODULE', 'error_404-module'); echo $e->getMessage() . '<br/><br/>In file <strong>' . $e->getFile() . '</strong> ar line ' . $e->getLine() . ''; // define('MODULE', 'error_404-block'); // not_found(sprintf('Blok <strong>%s</strong> nie istnieje.', u1), array( // 'Blok obsługujący nie jest zainstalowany', // $lang_system['FIRST_404_COUSE'], // $lang_system['SECOND_404_COUSE'])); } break; // Module // Module
private function getCategory() { global $sql, $plug; if (u1 == 'newest') { $order_by = 'added'; Kio::addTitle(t('Newest')); Kio::addBreadcrumb(t('Newest'), 'gallery/newest'); } else { $order_by = 'views'; Kio::addTitle(t('Popular')); Kio::addBreadcrumb(t('Popular'), 'gallery/popular'); } $this->name = t('Gallery'); $pager = new Pager('gallery/' . u1, Kio::getStat('images', 'gallery'), Kio::getConfig('limit', 'gallery')); //$query = $sql->setCache('gallery_'.u1.'_'.$pager->current)->query(' $query = $sql->query(' SELECT id, name, description, added, views, rating, comments, file_extension FROM ' . DB_PREFIX . 'gallery_images ORDER BY ' . $order_by . ' DESC LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $query->fetch()) { if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['name']); } $images[] = $row; } try { $tpl = new PHPTAL('modules/gallery/thumbnails.tpl.html'); $tpl->note = $note; $tpl->images = $images; $tpl->album = $album; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } }
define('DATE_FORMAT', 'Y-m-d'); 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'));
private function getMessage() { global $sql; Kio::addTitle(t(ucfirst(u1))); Kio::addBreadcrumb(t(ucfirst(u1)), 'pm/' . u1); // Get message content $message = $sql->query(' SELECT pm.*, u.nickname, u.group_id, u.avatar FROM ' . DB_PREFIX . 'pm pm LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id WHERE pm.id = ' . (int) u3 . ' AND pm.owner_id = ' . UID)->fetch(PDO::FETCH_ASSOC); // Message exists if ($message) { Kio::addTitle($message['subject']); Kio::addBreadcrumb($message['subject'], 'pm/' . u1 . '/read/' . u3); $this->subcodename = 'read'; // Sender/Recipient has id (is registered) if ($message['connector_id']) { $message['nickname'] = User::format($message['connector_id'], $message['nickname'], $message['group_id']); } // Mark as read if (!$message['is_read']) { $sql->exec(' UPDATE ' . DB_PREFIX . 'pm SET is_read = 1 WHERE id = "' . (int) $message['id'] . '"'); } try { $tpl = new PHPTAL('modules/pm/read.tpl.html'); $tpl->message = $message; return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } else { return not_found(); } }