Esempio n. 1
0
    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']);
                }
            }
        }
    }
Esempio n. 2
0
    public function getContent()
    {
        global $sql;
        //Lang::load('blocks/shoutbox/lang.*.php');
        $err = new Error();
        $note = new Notifier('note-shoutbox');
        $form['author'] = LOGGED ? User::$nickname : '';
        $form['message'] = '';
        if (isset($_POST['reply-shoutbox'])) {
            $form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
            $form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
            $err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
            $err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
            $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            // No errors
            if ($err->noErrors()) {
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
					VALUES (
						' . TIMESTAMP . ',
						"' . $form['author'] . '",
						"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
						' . UID . ',
						"' . IP . '")');
                $sql->clearCache('shoutbox');
                $note->success(t('Entry was added successfully.'));
                redirect(HREF . PATH . '#shoutbox');
            } else {
                $note->error($err->toArray());
            }
        }
        // If cache for shoutbox doesn't exists
        if (!($entries = $sql->getCache('shoutbox'))) {
            $query = $sql->query('
				SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
				FROM ' . DB_PREFIX . 'shoutbox s
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
				ORDER BY s.id DESC
				LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
            while ($row = $query->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    $row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
                }
                $entries[] = $row;
            }
            $sql->putCacheContent('shoutbox', $entries);
        }
        try {
            $tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
            $tpl->entries = $entries;
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e->getMessage());
            //echo Note::error($e->getMessage());
        }
    }
Esempio n. 3
0
    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.')));
        }
    }
Esempio n. 4
0
    public function getContent()
    {
        global $sql;
        $pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
        $pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
        $query = $sql->query('
			SELECT id, name, inline, members
			FROM ' . DB_PREFIX . 'groups
			ORDER BY display_order');
        while ($row = $query->fetch()) {
            if ($row['inline']) {
                $row['name'] = sprintf($row['inline'], $row['name']);
            }
            $groups[] = $row;
        }
        $query = $sql->query('
			SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
			FROM ' . DB_PREFIX . 'users u
			LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
			ORDER BY ' . $pager->orderBy . '
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset);
        while ($row = $query->fetch()) {
            $row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
            switch ($row['gender']) {
                case 1:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
                    break;
                case 2:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
                    break;
                default:
                    $row['gender'] = '';
            }
            $users[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/users/users.tpl.html');
            $tpl->sort = $pager->sorters;
            $tpl->users = $users;
            $tpl->groups = $groups;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 5
0
 /**
  * Sdsasdasdadasdasd
  * @param $items
  * @param $parent
  * @param $level
  */
 function generate($items = array(), $parent = 0, $level = 0)
 {
     global $cfg;
     if (!$items) {
         $items = $this->getItems();
     }
     // Reset the flag each time the function is called
     $is_parent = false;
     // Building tree
     foreach ($items as $key => $value) {
         if ($value['parent_id'] == $parent) {
             $current = false;
             // Link to front page
             if ($value['url'] == '/') {
                 $href = LOCAL;
                 if (!PATH || Kio::getConfig('front_page') == u0) {
                     $current = ' class="current"';
                 }
             } elseif (strpos($value['url'], '://') === false) {
                 //PATH == $value['url'] && $current = ' class="current"';
                 $href = HREF . $value['url'];
                 if (strpos(HREF . PATH . '/', $href . '/') !== false) {
                     $current = ' class="current"';
                 }
             } else {
                 $href = $value['url'];
             }
             if (!$is_parent) {
                 $is_parent = true;
                 $this->content .= '<ul class="level-' . $level . '">';
                 $level++;
             }
             $value['url'] ? $href = ' href="' . $href . '"' : ($current = $href = '');
             $this->content .= '<li' . $current . '><a' . $href . '>' . $value['name'] . '</a>';
             $this->generate($items, $key, $level);
             $this->content .= '</li>';
         }
     }
     // Close list if the wrapper above is opened
     if ($is_parent) {
         $this->content .= '</ul>';
     }
 }
Esempio n. 6
0
    public static function loadBlocks($sectors = array())
    {
        global $sql;
        if (true || Kio::getConfig('show_blocks')) {
            $query = $sql->setCache('blocks')->query('
				SELECT * FROM ' . DB_PREFIX . 'blocks
				WHERE type != 0
				ORDER BY display_order');
            while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                if (!$sectors || !empty($sectors[$row['sector']])) {
                    if (in_array($row['codename'], (array) $sectors[$row['sector']])) {
                        if ($row['content']) {
                            $block = new Block($row);
                            $block->name = $row['name'];
                        } else {
                            require_once ROOT . 'blocks/' . $row['codename'] . '/' . $row['codename'] . '.block.php';
                            $block = new $row['codename']($row);
                        }
                        self::$sectors[$row['sector']][$row['codename']] = $block;
                    }
                }
            }
        }
    }
Esempio n. 7
0
		<div id="path">
			<a href="' . LOCAL . '"><img style="margin-right: 5px;" src="' . LOCAL . 'themes/' . THEME . '/images/home.png" alt="Strona główna" />' . t('Home') . '</a>
			' . Kio::getBreadcrumbs() . '
		</div>';
}
// Site main content
echo '<div' . ($module->codename ? ' id="' . $module->codename . '"' : '') . ' class="module' . ($module->subcodename ? ' ' . $module->codename . '-' . $module->subcodename : '') . '">


<div class="module-content">
	<div class="module-header"><h2>' . $module->name . '</h2>' . Kio::getTabs(0) . '</div>
	' . $module->content . '
</div></div>';
?>
</div><!-- /CONTENT -->


</div>
</div>
</div><!-- /BODY -->

<div id="footer"><!-- FOOTER -->
<strong>Kio</strong>fol <strong>C</strong>ontent <strong>M</strong>anagment <strong>S</strong>ystem<br /><a href="http://www.kjofol.pl" onclick="target='new'"><b>KioCMS</b></a>
<div style="position: absolute; top: 5px; left: 5px;"><?php 
echo Kio::getTimer() . ' / ' . $sql->getCounter() . ' / ' . memory_get_usage();
?>
</div>
</div><!-- /FOOTER -->

</body>
</html>
Esempio n. 8
0
    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));
        }
    }
Esempio n. 9
0
function clock($time = TIMESTAMP, $date_format = null, $time_relative = true)
{
    if (!$date_format) {
        $date_format = Kio::getConfig('date_format');
    }
    if (Kio::getConfig('time_relative') && $time_relative) {
        switch (date('Y-m-d', $time)) {
            case TODAY:
                return date(sprintf(Kio::getConfig('relative_date_format'), Kio::$today), $time);
            case YESTERDAY:
                return date(sprintf(Kio::getConfig('relative_date_format'), Kio::$yesterday), $time);
            case TOMMOROW:
                return date(sprintf(Kio::getConfig('relative_date_format'), Kio::$tommorow), $time);
        }
    }
    if (TRANSLATE_DATE) {
        $month = date('n', $time);
        $day = date('N', $time);
        $date_format = str_replace(array('F', 'M', 'l', 'D'), array(Kio::$monthsFormated[$month], Kio::$monthsFormated[$month + 12], Kio::$daysFormated[$day], Kio::$daysFormated[$day + 7]), $date_format);
    }
    return date($date_format, $time);
}
Esempio n. 10
0
    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&apos;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);
            }
        }
    }
Esempio n. 11
0
 public static function format($id = false, $nickname = false, $group_id = false)
 {
     $group = Kio::getGroup($group_id);
     // $u_color - do czata / mozliwosc uzycia font-size: 40px
     return $nickname ? '<a href="' . HREF . 'profile/' . $id . '/' . clean_url($nickname) . '" class="nickname"' . ($group_id ? ' title="' . $group['name'] . '"' : '') . '>' . ($group['inline'] ? sprintf($group['inline'], $nickname) : $nickname) . '</a>' : t('???');
 }
Esempio n. 12
0
 public function __construct()
 {
     $this->name = t('Shoutbox');
     Kio::addStyle('blocks/shoutbox/shoutbox.css');
 }
Esempio n. 13
0
 public function __construct()
 {
     Kio::addTitle(t('Log in'));
     Kio::addBreadcrumb(t('Log in'), 'login');
 }
Esempio n. 14
0
 public static function setTimeLocales()
 {
     global $cfg;
     date_default_timezone_set(self::$timeZones[!empty(User::$timeZone) ? User::$timeZone : Kio::getConfig('time_zone')]);
     // Translate days and months in date()
     if (TRANSLATE_DATE && preg_match('#F|M|l|d#', self::getConfig('date_format') . self::getConfig('short_date_format'))) {
         self::$months = self::$monthsFormated = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 13 => 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
         self::$days = self::$daysFormated = array(1 => 'Monday', 'Tu', 'We', 'Th', 'Fr', 'Saturday', 'Sunday', 8 => 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
         for ($i = 1; $i < 25; $i++) {
             self::$monthsFormated[$i] = strtr(addcslashes(t(self::$months[$i]), 'A..z'), array('l' => '&#108;', 'D' => '&#68;'));
         }
         for ($i = 1; $i < 15; $i++) {
             self::$daysFormated[$i] = strtr(addcslashes(t(self::$days[$i]), 'A..z'), array('l' => '&#108;', 'D' => '&#68;'));
         }
     }
     if (Kio::getConfig('time_relative')) {
         self::$today = strtr(addcslashes(t('Today'), 'A..z'), array('l' => '&#108;', 'D' => '&#68;'));
         self::$yesterday = strtr(addcslashes(t('Yesterday'), 'A..z'), array('l' => '&#108;', 'D' => '&#68;'));
         self::$tommorow = strtr(addcslashes(t('Tommorow'), 'A..z'), array('l' => '&#108;', 'D' => '&#68;'));
     }
 }
Esempio n. 15
0
    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);
            }
        }
    }
Esempio n. 16
0
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     Kio::addCssFile('blocks/calendar/calendar.css');
 }
Esempio n. 17
0
 function sort($elements, $default, $tendency, $prefix = false)
 {
     global $kio, $cfg;
     $start = array_search('sort', Kio::$url);
     $js = Kio::getConfig('javascript_sort') ? '#' : '';
     if (Kio::$url[$start] == 'sort' && in_array(Kio::$url[$start + 1], $elements) && (Kio::$url[$start + 2] == 'asc' || Kio::$url[$start + 2] == 'desc')) {
         $by = array(Kio::$url[$start + 1], Kio::$url[$start + 2], Kio::$url[$start + 2] == 'asc' ? 'desc' : 'asc');
         $this->start = isset(Kio::$url[$start + 3]) ? Kio::$url[$start + 3] : 0;
         // Update cursor position
         $url = '/sort/' . $by[0] . '/' . $by[1];
         $sorting = true;
     } else {
         $by = array($default, $tendency, $tendency == 'asc' ? 'desc' : 'asc');
         $url = '';
         $sorting = false;
         //$this->start = Kio::$url[substr_count($url, '/') + 1];  // Update cursor position
     }
     foreach ($elements as $key => $value) {
         $this->sorters[$value] = '<a href="' . $js . $this->url . '/sort/' . $value . '/' . ($by[0] == $value ? $by[2] . '" class="sort ' . $by[1] . '">' . $key : 'asc" class="sort">' . $key) . '</a>';
     }
     $this->orderBy = $sorting ? $prefix . $by[0] . ' <> "" ' . $by[2] . ', ' . $prefix . $by[0] . ' ' . $by[1] : $prefix . $by[0] . ' ' . $by[1];
     $this->url .= $url;
     $this->calculate();
     return $this;
 }
Esempio n. 18
0
    private function getEntries()
    {
        global $sql;
        $start = array_search('edit_comment', Kio::$url);
        $edited_id = $start && ctype_digit(Kio::$url[$start + 1]) ? Kio::$url[$start + 1] : '';
        if (Kio::getConfig('order_by', 'comments') == 'DESC') {
            $x = $this->total + 1;
            $ascending = false;
        } else {
            $x = 1;
            $ascending = true;
        }
        $query = $sql->query('
			SELECT c.comment_id, c.comment_author, c.comment_author_id, c.comment_added,
				c.comment_message, c.comment_backlink, u.nickname, u.group_id, u.avatar
			FROM ' . DB_PREFIX . 'comments c
			LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = c.comment_author_id
			WHERE c.comment_owner_child_id = ' . $this->connector_id . ' AND c.comment_owner = "' . u0 . '"
			ORDER BY c.comment_added ' . Kio::getConfig('order_by', 'comments'));
        while ($row = $query->fetch()) {
            $row['x'] = $ascending ? $x++ : $x--;
            if ($edited_id == $row['comment_id']) {
                $this->edited = $row;
                $edited_x = $x;
            }
            if ($row['comment_author_id']) {
                $row['comment_author'] = User::format($row['comment_author_id'], $row['nickname'], $row['group_id']);
            }
            $entries[] = $row;
        }
        return $entries;
    }
Esempio n. 19
0
define('AUTOLINKS', 2);
define('EMOTICONS', 3);
define('CENSURE', 4);
define('PRE', 5);
define('TRIM', 1);
define('NO_HTML', 2);
define('ANTISPAM', 3);
define('ANTIFLOOD_IP', 4);
define('ANTIFLOOD_COOKIE', 5);
// Define constants (BBCode and parameters for User::get*)
define('BY_NICKNAME', 'nickname');
define('BY_LOGNAME', 'logname');
define('BY_ID', 'id');
User::init();
// Set timezones and assign day/month names
Kio::setTimeLocales();
define('AUTH', md5(PATH . IP . $_SERVER['HTTP_USER_AGENT'] . User::$logname . User::$authCode . DB_HOST . DB_PORT . DB_NAME . DB_USER . CACHE_DIR . date('z')));
define('CORRECT_AUTH', isset($_POST['auth']) && $_POST['auth'] == AUTH ? true : false);
define('SORT_PATTERN', '(/[0-9]+|(/sort/[A-z0-9_]+/(desc|asc)(/[0-9]+)?))?');
//// Blocks
//if (!($kio->blocks = $sql->getCache('blocks')))
//{
//	$query = $sql->query('
//		SELECT * FROM '.DB_PREFIX.'blocks
//		WHERE id NOT IN($cfg[MODULE]['disabled_blocks'])
//		ORDER BY position');
//
//	$sql->putCacheContent('groups', $kio->groups);
//}
// lang_translations {translation_id, translation_phrase_id, translation_value}
// lang_phrases {phrase_id, phrase_value, phrase_holder}
Esempio n. 20
0
    private function formSumbit()
    {
        global $sql;
        $form['author'] = isset($_POST['add']) && LOGGED ? User::$nickname : filter($_POST['author'], 100);
        $form['email'] = strtolower(filter($_POST['email'], 100));
        $form['website'] = filter($_POST['website'], 100);
        $form['message'] = filter($_POST['message'], Kio::getConfig('message_max', 'guestbook'), TRIM . NO_HTML . ANTISPAM . ANTIFLOOD_COOKIE, 'guestbook');
        $this->err->setError('author_empty', t('Author field is required.'))->condition(!$form['author'])->setError('author_exists', t('The nickname you used belongs to a registered user.'))->condition(isset($_POST['add']) && !LOGGED && is_registered($form['author']))->setError('email_invalid', t('E-mail address you entered is invalid.'))->condition($form['email'] && !is_email($form['email']))->setError('message_empty', t('Message field is required.'))->condition(!trim($form['message']))->setError('message_spam', t('ERROR_MESSAGE_SPAM'))->condition()->setError('flood', t(defined('FLOOD') && FLOOD == 1 ? 'ERROR_FLOOD' : 'ERROR_FLOOD2'))->condition(!$form['edit_mode'] && defined('FLOOD'))->setError('incorrect_auth', t('ERROR_INCORRECT_AUTH'))->condition($_POST['auth'] != AUTH);
        // No errors
        if ($this->err->noErrors()) {
            // Add
            if (isset($_POST['add'])) {
                // Nie działa rollback
                //$sql->beginTransaction();
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'guestbook
						(added, author, author_id, author_ip, email, website, message)
					VALUES(
						' . TIMESTAMP . ',
						"' . (!LOGGED ? $form['author'] : '') . '",
						' . UID . ',
						"' . IP . '",
						"' . $form['email'] . '",
						"' . ($form['website'] && !strpos($form['website'], '://') ? 'http://' : '') . $form['website'] . '",
						"' . $form['message'] . '")');
                $sql->exec('
					UPDATE ' . DB_PREFIX . 'stats
					SET stat_value = stat_value + 1
					WHERE stat_name = "entries"
						AND stat_owner = "guestbook"');
                $sql->clearCacheGroup('guestbook_*');
                $sql->clearCache('stats');
                setcookie(COOKIE . '-guestbook', true, TIMESTAMP + Kio::getConfig('flood_interval', 'guestbook'), '/');
                $this->note->success(array(t('Entry was added successfully.'), t('<a href="#dd">Show me my enty</a>')));
                redirect(HREF . 'guestbook');
                //$sql->commit();
            } else {
                $form['author_id'] = User::getId(BY_NICKNAME, $form['author']);
                if ($form['author_id']) {
                    $form['author'] = '';
                }
                // Dwukrotny limit treści dla moderatorów
                $sql->exec('
						UPDATE ' . DB_PREFIX . 'guestbook
						SET
							author = "' . $form['author'] . '",
							author_id = ' . (int) $form['author_id'] . ',
							email = "' . $form['email'] . '",
							website = "' . $form['website'] . '",
							message = "' . filter($_POST['message'], Kio::getConfig('message_max', 'guestbook') * 1.5) . '"
						WHERE id = ' . $edited_id);
                $sql->clearCacheGroup('guestbook_*');
                $this->note->success(t('Entry was modified successfully.'));
                redirect(HREF . 'guestbook');
            }
        } else {
            return $this->note->restore()->error($this->err->toArray());
        }
    }
Esempio n. 21
0
    private function getAlbumList()
    {
        global $sql;
        $this->subcodename = 'albums';
        $pager = new Pager('pm/' . u1, Kio::getStat('images', 'gallery'), Kio::getConfig('limit', 'gallery'));
        //		$albums = Cache::get('gallery_albums_'.$pager->current.'.txt');
        $albums = $sql->setCache('gallery_' . $pager->current)->query('
			SELECT id, name, description, added, thumbnail, images
			FROM ' . DB_PREFIX . 'gallery_albums
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset)->fetchAll(PDO::FETCH_ASSOC);
        try {
            $tpl = new PHPTAL('modules/gallery/gallery.tpl.html');
            $tpl->albums = $albums;
            $tpl->pager = $pager;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 22
0
    public function getContent()
    {
        global $sql;
        $this->err = new Error();
        $this->pager = new Pager('guestbook', Kio::getStat('entries', 'guestbook'), Kio::getConfig('limit', 'guestbook'));
        $show_form = true;
        $entries = $this->getEntries();
        // Editing entry
        if (ctype_digit(u2)) {
            // guestbook/edit/u2
            $edited_id = u1 == 'edit' ? u2 : '';
            if (!User::hasPermit('guestbook edit')) {
                $this->note->error(t('You don&apos;t have access to edit entries.'));
                $show_form = false;
            } else {
                if ($edited_id) {
                    $row = $sql->query('
					SELECT id, added, author, author_id, author_ip, email, website, message
					FROM ' . DB_PREFIX . 'guestbook
					WHERE id = ' . $edited_id)->fetch();
                    // Entry exists
                    if ($row) {
                        $form = $row;
                        $this->edit_mode = true;
                        if (!$row['author']) {
                            $form['author'] = User::getNickname(BY_ID, $row['author_id']);
                        }
                    } else {
                        $this->note->error(t('Selected entry doesn&apos;t exist.'));
                    }
                }
            }
        }
        if (!$this->edit_mode) {
            $form['author'] = User::$nickname;
        }
        // Form action
        $add = isset($_POST['add']) ? true : false;
        $edit = isset($_POST['edit']) ? true : false;
        // On form submit
        if ($add || $edit) {
            $form = $this->formSumbit();
        } else {
            if (isset($_POST['delete_id']) && ctype_digit($_POST['delete_id']) && $_POST['auth'] == AUTH && User::hasPermit('guestbook delete')) {
                $sql->exec('
				UPDATE ' . DB_PREFIX . 'stats SET content = content - 1 WHERE name = "guestbook_entries";
				DELETE FROM ' . DB_PREFIX . 'guestbook WHERE id = ' . $_POST['delete_id']);
                $sql->clearCacheGroup('guestbook_*');
            }
        }
        try {
            $tpl = new PHPTAL('modules/guestbook/guestbook.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'guestbook');
            $tpl->form = $form;
            $tpl->edit_mode = $this->edit_mode;
            $tpl->entries = $entries;
            $tpl->err = $this->err->toArray();
            $tpl->show_form = $show_form;
            $tpl->note = $this->note;
            $tpl->pagination = $this->pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 23
0
                    //				not_found(t('Podstrona <strong>%page</strong> nie istnieje.', array('%page' => u0)), array(
                    //					'Moduł obsługujący nie jest zainstalowany.',
                    //					'FIRST_404_COUSE',
                    //					'SECOND_404_COUSE'));
                }
        }
    } else {
        try {
            $codename = Kio::getConfig('front_page');
            if (!Module::exists($codename)) {
                throw new Exception(t('Module dosn&apos;t exists'));
            }
            require_once ROOT . 'modules/' . $codename . '/' . $codename . '.module.php';
            $module = new $codename();
            echo $module->getContent();
            define('MODULE', $codename);
        } catch (Exception $e) {
            define('MODULE', 'error_404-module');
            echo $e->getMessage() . '<br/>' . $e->getFile() . ':' . $e->getLine();
        }
        //if (!$module->name) $module->name = end($kio->path);
    }
}
if (!$module->name) {
    $module->name = Kio::getModuleName();
}
$module->content = ob_get_contents();
ob_end_clean();
//$kio->blocks_disabled = ${MODULE}['blocks'] ? ${MODULE}['blocks'] : $cfg->system['blocks'];
require_once ROOT . 'themes/' . THEME . '/' . THEME . '.theme.php';
unset($config, $system, $kio, $user, $form, $lang, $lang_system, $module, $stats, $permit, $groups, $sql);
Esempio n. 24
0
    public function getContent()
    {
        global $sql;
        $err = new Error();
        $form = array();
        if (Kio::getConfig('informations', 'contact')) {
            $info = Notifier::factory('note-contact_info')->info(parse(Kio::getConfig('informations', 'contact'), BBCODE . AUTOLINKS . EMOTICONS . CENSURE . PRE));
        }
        if (isset($_POST['send'])) {
            // Form values
            $form = array('receiver' => filter($_POST['receiver'], 100), 'sender' => LOGGED ? User::$nickname : filter($_POST['sender'], 100), 'email' => LOGGED ? User::$email : filter($_POST['email'], 100), 'subject' => filter($_POST['subject'], 100), 'message' => filter($_POST['message'], 250));
            if (!empty($_COOKIE[COOKIE . '-flood-contact']) && Kio::getConfig('flood_interval')) {
                $err->setError('flood', t('ERROR_FLOOD'));
            } else {
                // Errors
                if (!LOGGED) {
                    $err->setError('sender_empty', t('Sender field is required.'))->condition(!$form['sender']);
                    $err->setError('sender_exists', t('ERROR_SENDER_EXISTS'))->condition(is_registered($form['sender'], 'nickname'));
                    $err->setError('email_empty', t('E-mail address field is required.'))->condition(!$form['email']);
                    $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
                }
                //				$err->setError('phone_invalid', t('ERROR_PHONE_INVALID'))
                //					->condition($form['phone'] && !preg_match('#^[0-9 ()+-]+$#', $form['phone']));
                $err->setError('subject_empty', t('Subject field is required.'))->condition(!$form['subject']);
                $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            }
            if ($err->noErrors()) {
                $from = "From: {$form['email']}2";
                $msg = "Imię: {$imie}\nE-Mail: {$form['email']}2\nTelefon: {$telefon}\n\nTreść wiadomości:\n{$form['message']}\n\n\n----\nWiadomość została wysłana ze strony {$adres}\nIP: {$ip}";
                echo mail($form['email'], $temat, $msg, $from) ? $note->success(t('SUCCESS')) . redirect() : $note->error(t('Wystąpił błąd, spróbuj wysłać później'));
                if (Kio::getConfig('flood_interval')) {
                    setcookie(COOKIE . '-contact', 'true', TIMESTAMP + Kio::getConfig('flood_interval') + 1, '/');
                }
                $to = "*****@*****.**";
                $subject = "Test mail";
                $message = "Hello! This is a simple email message.";
                $from = "*****@*****.**";
                $headers = "From: {$from}";
                mail($to, $subject, $message, $headers);
            } else {
                $this->note->error($err->toArray());
            }
        }
        $stmt = $sql->setCache('contact')->prepare('
			SELECT id, nickname, group_id
			FROM ' . DB_PREFIX . 'users
			WHERE id IN (:receivers)');
        $stmt->bindParam(':receivers', Kio::getConfig('receivers', 'contact'));
        $stmt->execute();
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $row['g_name'] = Kio::getGroup($row['group_id'], 'name');
            $receivers[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/contact/contact.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'contact');
            $tpl->form = $form;
            $tpl->user = User::toArray();
            $tpl->receivers = $receivers;
            $tpl->err = $err->toArray();
            $tpl->note = $this->note;
            $tpl->info = isset($info) ? $info : '';
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 25
0
    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();
        }
    }