コード例 #1
0
 public function getContent()
 {
     // User is logged in
     if (LOGGED) {
         $this->subcodename = 'logged';
         $tpl = new PHPTAL('blocks/user_panel/logged.html');
         $tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
         $pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
         $tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
         return $tpl->execute();
     } else {
         $err = new Error();
         $note = new Notifier('note-user_panel');
         $this->subcodename = 'not_logged';
         $form = array('logname' => null, 'password' => null);
         if ($_POST['login'] && $_POST['user_panel']) {
             $form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
             $form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
             $err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
             $err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
             $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
             $err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
             if ($err->noErrors()) {
                 redirect('./');
             } else {
                 $note->error($err->toArray());
             }
         }
         $tpl = new PHPTAL('blocks/user_panel/not_logged.html');
         $tpl->note = $note;
         $tpl->form = $form;
         $tpl->err = $err->toArray();
         return $tpl->execute();
     }
 }
コード例 #2
0
ファイル: shoutbox.block.php プロジェクト: rafalenden/KioCMS
    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());
        }
    }
コード例 #3
0
 /**
  * format
  * This takes the current playlist object and gussies it up a little
  * bit so it is presentable to the users
  */
 public function format($details = true)
 {
     $this->f_name = $this->name;
     $this->f_type = $this->type == 'private' ? UI::get_icon('lock', T_('Private')) : '';
     if ($details) {
         $client = new User($this->user);
         $client->format();
         $this->f_user = $client->f_name;
     }
 }
コード例 #4
0
ファイル: users.module.php プロジェクト: rafalenden/KioCMS
    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);
        }
    }
コード例 #5
0
ファイル: shoutbox.rss.php プロジェクト: rafalenden/KioCMS
    public function getContent()
    {
        global $sql, $user, $cfg;
        //Lang::load('blocks/shoutbox/lang.*.php');
        $err = new Error();
        $note = new Notifier('note-shoutbox');
        $form = array();
        $form['author'] = $user->nickname;
        if ($_POST['reply-shoutbox']) {
            $form['author'] = LOGGED ? $user->nickname : filter($_POST['author-shoutbox'], 100);
            $form['message'] = filter($_POST['message-shoutbox'], $cfg->shoutbox['message_max']);
            $err->author_empty(t('Field <strong>author</strong> can not be empty.'), !$form['author']);
            $err->author_exists(t('Entered <strong>nickname</strong> is registered.'), !LOGGED && is_registered($form['author']));
            $err->message_empty(t('Field <strong>message</strong> can not be empty.'), !$form['message']);
            // No errors
            if (!$err->count()) {
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
					VALUES (
						' . TIMESTAMP . ',
						"' . $form['author'] . '",
						"' . cut($form['message'], $cfg->shoutbox['message_max']) . '",
						' . $user->id . ',
						"' . IP . '")', 'shoutbox.txt');
                $note->success(t('Entry was added successfully.'));
                redirect(HREF . PATH . '#shoutbox');
            } else {
                $note->error($err);
            }
        }
        // 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, ' . DB_PREFIX . 'users u
				WHERE u.id = s.author_id
				ORDER BY s.id DESC
				LIMIT ' . $cfg->shoutbox['limit']);
            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'], $cfg->shoutbox['parser']);
                }
                $entries[] = $row;
            }
            $sql->putCacheContent('shoutbox', $entries);
        }
        try {
            $tpl = new PHPTAL('blocks/shoutbox/sbox_overall.html');
            $tpl->cfg = $cfg;
            $tpl->entries = $entries;
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            $tpl->user = $user;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e->getMessage());
            //echo Note::error($e->getMessage());
        }
    }
コード例 #6
0
ファイル: entries.php プロジェクト: rafalenden/KioCMS
// KioCMS - Kiofol Content Managment System
// modules/news/admin/entries/index.php
if ($kio->stats['news_entries']) {
    $pager = new Pager('admin/modules/news', $kio->stats['news_entries']);
    $pager->limit()->sort(array(t('ID') => 'n_id', t('Title') => 'n_title', t('Language') => 'lang', t('Content') => 'content', t('Author') => 'nickname', t('Category') => 'c_name', t('Added') => 'added'), 'added', 'desc');
    $query = $sql->query('
		SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.*, n.id n_id, n.title n_title
		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
		ORDER BY ' . $pager->order . '
		LIMIT ' . $pager->limit . '
		OFFSET ' . $pager->offset);
    while ($row = $query->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']) . '/' : null) . clean_url($row['title']);
        $entries[] = $row;
    }
    $tpl = new PHPTAL('modules/news/admin/entries.html');
    $tpl->stats = $kio->stats;
    $tpl->entries = $entries;
    $tpl->sort = $pager->sorters;
    $tpl->limit_form = $pager->limit_form;
    $tpl->pagination = $pager->links();
    echo $tpl->execute();
} else {
    echo $lang_admin['NULL'];
}
コード例 #7
0
ファイル: shoutbox.class.php プロジェクト: nioc/ampache
 public function get_display($details = true, $jsbuttons = false)
 {
     $object = Shoutbox::get_object($this->object_type, $this->object_id);
     $object->format();
     $img = $this->get_image();
     $html = "<div class='shoutbox-item'>";
     $html .= "<div class='shoutbox-data'>";
     if ($details && $img) {
         $html .= "<div class='shoutbox-img'>" . $img . "</div>";
     }
     $html .= "<div class='shoutbox-info'>";
     if ($details) {
         $html .= "<div class='shoutbox-object'>" . $object->f_link . "</div>";
         $html .= "<div class='shoutbox-date'>" . date("Y/m/d H:i:s", $this->date) . "</div>";
     }
     $html .= "<div class='shoutbox-text'>" . $this->f_text . "</div>";
     $html .= "</div>";
     $html .= "</div>";
     $html .= "<div class='shoutbox-footer'>";
     if ($details) {
         $html .= "<div class='shoutbox-actions'>";
         if ($jsbuttons) {
             $html .= Ajax::button('?page=stream&action=directplay&playtype=' . $this->object_type . '&' . $this->object_type . '_id=' . $this->object_id, 'play', T_('Play'), 'play_' . $this->object_type . '_' . $this->object_id);
             $html .= Ajax::button('?action=basket&type=' . $this->object_type . '&id=' . $this->object_id, 'add', T_('Add'), 'add_' . $this->object_type . '_' . $this->object_id);
         }
         if (Access::check('interface', '25')) {
             $html .= "<a href=\"" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=" . $this->object_type . "&id=" . $this->object_id . "\">" . UI::get_icon('comment', T_('Post Shout')) . "</a>";
         }
         $html .= "</div>";
     }
     $html .= "<div class='shoutbox-user'>" . T_('by') . " ";
     if ($this->user > 0) {
         $user = new User($this->user);
         $user->format();
         if ($details) {
             $html .= $user->f_link;
         } else {
             $html .= $user->username;
         }
     } else {
         $html .= T_('Guest');
     }
     $html .= "</div>";
     $html .= "</div>";
     $html .= "</div>";
     return $html;
 }
コード例 #8
0
ファイル: ampache_rss.class.php プロジェクト: nioc/ampache
 /**
  * load_latest_shout
  * This loads in the latest added shouts
  * @return array
  */
 public static function load_latest_shout()
 {
     $ids = Shoutbox::get_top(10);
     $results = array();
     foreach ($ids as $id) {
         $shout = new Shoutbox($id);
         $shout->format();
         $object = Shoutbox::get_object($shout->object_type, $shout->object_id);
         $object->format();
         $user = new User($shout->user);
         $user->format();
         $xml_array = array('title' => $user->username . ' ' . T_('on') . ' ' . $object->get_fullname(), 'link' => $object->link, 'description' => $shout->text, 'image' => Art::url($shout->object_id, $shout->object_type, null, 2), 'comments' => '', 'pubDate' => date("c", $shout->date));
         $results[] = $xml_array;
     }
     // end foreach
     return $results;
 }
コード例 #9
0
ファイル: share.class.php プロジェクト: cheese1/ampache
 public function format($details = true)
 {
     if ($details) {
         $object = new $this->object_type($this->object_id);
         $object->format();
         $this->f_name = $object->get_fullname();
         $this->f_object_link = $object->f_link;
         $user = new User($this->user);
         $user->format();
         $this->f_user = $user->f_name;
     }
     $this->f_allow_stream = $this->allow_stream;
     $this->f_allow_download = $this->allow_download;
     $this->f_creation_date = date("Y-m-d H:i:s", $this->creation_date);
     $this->f_lastvisit_date = $this->lastvisit_date > 0 ? date("Y-m-d H:i:s", $this->creation_date) : '';
 }
コード例 #10
0
ファイル: wanted.class.php プロジェクト: cheese1/ampache
 /**
  * Format data.
  */
 public function format()
 {
     if ($this->artist) {
         $artist = new Artist($this->artist);
         $artist->format();
         $this->f_artist_link = $artist->f_link;
     } else {
         $wartist = Wanted::get_missing_artist($this->artist_mbid);
         $this->f_artist_link = $wartist['link'];
     }
     $this->link = AmpConfig::get('web_path') . "/albums.php?action=show_missing&mbid=" . $this->mbid . "&artist=" . $this->artist . "&artist_mbid=" . $this->artist_mbid . "\" title=\"" . $this->name;
     $this->f_link = "<a href=\"" . $this->link . "\">" . $this->name . "</a>";
     $user = new User($this->user);
     $user->format();
     $this->f_user = $user->f_name;
 }
コード例 #11
0
    public function getContent()
    {
        global $sql;
        $this->err = new Error();
        $pager = new Pager('guestbook', Kio::getStat('entries', 'guestbook'), Kio::getConfig('limit', 'guestbook'));
        if (Kio::getConfig('order_by', 'guestbook') == 'DESC') {
            $x = $pager->items + 1 - $pager->offset;
            $y = '$x--;';
        } else {
            $x = $pager->offset;
            $y = '$x++;';
        }
        //		$entries = $sql->getCache('guestbook_'.$pager->current);
        if (!$entries) {
            $stmt = $sql->query('
				SELECT gb.id, gb.added, gb.author, gb.email, gb.website, gb.message, gb.author_id, gb.author_ip,
					u.nickname, u.group_id, u.avatar, u.signature
				FROM ' . DB_PREFIX . 'guestbook gb
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = gb.author_id
				ORDER BY gb.id ' . Kio::getConfig('order_by', 'guestbook') . '
				LIMIT ' . $pager->limit . '
				OFFSET ' . $pager->offset);
            if ($stmt->rowCount()) {
                while ($row = $stmt->fetch()) {
                    eval($y);
                    $row['number'] = $x;
                    if ($row['author_id']) {
                        $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    }
                    $row['message'] = parse($row['message'], Kio::getConfig('parsers', 'guestbook'));
                    $row['signature'] = $row['signature'] ? parse($row['signature'], Kio::getConfig('parsers', 'guestbook')) : '';
                    $entries[] = $row;
                }
                $sql->putCacheContent('guestbook_' . $pager->current, $entries);
            } else {
                $this->note->info('Jeszcze nikt nie dodał żadnego wpisu.');
            }
        }
        // Editing entry
        if (ctype_digit(u2)) {
            // guestbook/edit/u2
            $edited_id = u1 == 'edit' ? u2 : '';
            if (!User::hasPermit('guestbook edit')) {
                $this->note->error(t('You do not have access to edit entries.'));
            } 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;
                        $form['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 (!$form['edit_mode']) {
            $form['author'] = User::$nickname;
        }
        // Form action
        $add = $_POST['add'] ? true : false;
        $edit = $_POST['edit'] ? true : false;
        // On form submit
        if ($add || $edit) {
            $this->formSumbit();
        } else {
            if (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->entries = $entries;
            $tpl->err = $this->err->toArray();
            $tpl->note = $this->note;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
コード例 #12
0
ファイル: box.php プロジェクト: rafalenden/KioCMS
				AND owner_id = ' . $user->id);
    }
    redirect(HREF . PATH);
}
$stmt = $sql->query('
	SELECT pm.*, u.nickname, u.group_id
	FROM ' . DB_PREFIX . 'pm pm
	LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id
	WHERE pm.owner_id = ' . $user->id . ' AND pm.folder = ' . $folder . '
	ORDER BY ' . $pager->order . '
	LIMIT ' . $pager->limit . '
	OFFSET ' . $pager->offset);
if ($stmt->rowCount()) {
    while ($row = $stmt->fetch()) {
        if ($row['connector_id']) {
            $row['nickname'] = User::format($row['connector_id'], $row['nickname'], $row['group_id']);
        }
        $messages[] = $row;
    }
    try {
        $tpl = new PHPTAL('modules/pm/box.html');
        $tpl->cfg = $cfg;
        $tpl->messages = $messages;
        $tpl->sort = $pager->sorters;
        $tpl->total = $user->{'pm_' . u1};
        $tpl->kio = $kio;
        $tpl->max = $cfg->pm[u1 . '_max'];
        $tpl->note = $note;
        $tpl->pager = $pager;
        $tpl->pagination = $pager->getLinks();
        echo $tpl->execute();
コード例 #13
0
ファイル: xml_data.class.php プロジェクト: cheese1/ampache
 public static function podcast(library_item $libitem)
 {
     $xml = new SimpleXMLElement('<rss />');
     $xml->addAttribute("version", "2.0");
     $xml->addAttribute("xmlns:xmlns:atom", "http://www.w3.org/2005/Atom");
     $xml->addAttribute("xmlns:xmlns:itunes", "http://www.itunes.com/dtds/podcast-1.0.dtd");
     $xchannel = $xml->addChild("channel");
     $xchannel->addChild("title", $libitem->get_fullname() . " Podcast");
     $xlink = $xchannel->addChild("atom:link");
     $xlink->addAttribute("type", "text/html");
     $xlink->addAttribute("href", $libitem->link);
     if (Art::has_db($libitem->id, get_class($libitem))) {
         $ximg = $xchannel->addChild("xmlns:itunes:image");
         $ximg->addAttribute("href", Art::url($libitem->id, get_class($libitem)));
     }
     $summary = $libitem->get_description();
     if (!empty($summary)) {
         $xchannel->addChild("xmlns:itunes:summary", $summary);
     }
     $xchannel->addChild("xmlns:itunes:category", "Music");
     $owner = $libitem->get_user_owner();
     if ($owner) {
         $user_owner = new User($owner);
         $user_owner->format();
         $xowner = $xchannel->addChild("xmlns:itunes:owner");
         $xowner->addChild("xmlns:itunes:name", $user_owner->f_name);
     }
     $medias = $libitem->get_medias();
     foreach ($medias as $media_info) {
         $media = new $media_info['object_type']($media_info['object_id']);
         $media->format();
         $xitem = $xchannel->addChild("item");
         $xitem->addChild("title", $media->get_fullname());
         if ($media->f_artist) {
             $xitem->addChild("xmlns:itunes:author", $media->f_artist);
         }
         $xmlink = $xitem->addChild("link");
         $xmlink->addAttribute("href", $media->link);
         $xitem->addChild("guid", $media->link);
         if ($media->addition_time) {
             $xitem->addChild("pubDate", date("r", $media->addition_time));
         }
         $description = $media->get_description();
         if (!empty($description)) {
             $xitem->addChild("description", $description);
         }
         $xitem->addChild("xmlns:itunes:duration", $media->f_time);
         $xencl = $xitem->addChild("enclosure");
         $xencl->addAttribute("type", $media->mime);
         $xencl->addAttribute("length", $media->size);
         $surl = $media_info['object_type']::play_url($media_info['object_id']);
         $xencl->addAttribute("url", $surl);
     }
     $xmlstr = $xml->asXml();
     // Format xml output
     $dom = new DOMDocument();
     $dom->loadXML($xmlstr);
     $dom->formatOutput = true;
     return $dom->saveXML($dom->documentElement);
 }
コード例 #14
0
ファイル: read.php プロジェクト: rafalenden/KioCMS
	FROM ' . DB_PREFIX . 'news n
	LEFT JOIN ' . DB_PREFIX . 'users AS u ON u.id = n.author_id
	LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id
	WHERE n.id = ' . u2);
if ($entry = $stmt->fetch(PDO::FETCH_ASSOC)) {
    if ($entry['description']) {
        $kio->description = $entry['description'];
    }
    if ($entry['keywords']) {
        $kio->keywords = $entry['keywords'];
    }
    if ($entry['c_name']) {
        $kio->addPath($entry['c_name'], 'news/category/' . $entry['c_id'] . '/' . clean_url($entry['c_name']));
    }
    if ($entry['author_id']) {
        $entry['author'] = User::format($entry['author_id'], $entry['nickname'], $entry['group_id']);
    }
    $entry['url'] = 'news/read/' . u2 . '/' . ($entry['c_name'] ? clean_url($entry['c_name']) . '/' : '') . clean_url($entry['title']);
    $module->subcodename = 'read';
    $kio->addPath($entry['title'], $entry['url']);
    try {
        $tpl = new PHPTAL('modules/news/read.html');
        $tpl->cfg = $cfg;
        $tpl->entry = $entry;
        $tpl->comments = $plug->comments(u2, 'news', $entry['comments'], $entry['url']);
        echo $tpl->execute();
    } catch (Exception $e) {
        echo template_error($e);
    }
} else {
    not_found(t('Selected entry number does not exists.'));
コード例 #15
0
ファイル: comments.plugin.php プロジェクト: rafalenden/KioCMS
    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;
    }
コード例 #16
0
ファイル: news.module.php プロジェクト: rafalenden/KioCMS
    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);
            }
        }
    }
コード例 #17
0
ファイル: privatemsg.class.php プロジェクト: cheese1/ampache
 public function format($details = true)
 {
     $this->f_subject = scrub_out($this->subject);
     $this->f_message = scrub_out($this->message);
     $this->f_creation_date = date("Y/m/d H:i:s", $this->creation_date);
     $from_user = new User($this->from_user);
     $from_user->format();
     $this->f_from_user_link = $from_user->f_link;
     $to_user = new User($this->to_user);
     $to_user->format();
     $this->f_to_user_link = $to_user->f_link;
     $this->link = AmpConfig::get('web_path') . '/pvmsg.php?pvmsg_id=' . $this->id;
     $this->f_link = "<a href=\"" . $this->link . "\">" . $this->f_subject . "</a>";
 }
コード例 #18
0
ファイル: gallery.module.php プロジェクト: rafalenden/KioCMS
    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);
        }
    }
コード例 #19
0
ファイル: search.ajax.php プロジェクト: nioc/ampache
                $results[] = array('type' => T_('Missing Artists'), 'link' => AmpConfig::get('web_path') . '/artists.php?action=show_missing&mbid=' . $r['mbid'], 'label' => $r['name'], 'value' => $r['name'], 'rels' => '', 'image' => '');
                $i++;
                if ($i >= $limit) {
                    break;
                }
            }
        }
        if ($target == 'user' && AmpConfig::get('sociable')) {
            $searchreq = array('limit' => $limit, 'type' => 'user', 'rule_1_input' => $search, 'rule_1_operator' => '2', 'rule_1' => 'username');
            $sres = Search::run($searchreq);
            // Litmit not reach, new search with another operator
            if (count($sres) < $limit) {
                $searchreq['limit'] = $limit - count($sres);
                $searchreq['rule_1_operator'] = '0';
                $sres = array_unique(array_merge($sres, Search::run($searchreq)));
            }
            foreach ($sres as $id) {
                $user = new User($id);
                $user->format();
                $avatar = $user->get_avatar();
                $results[] = array('type' => T_('Users'), 'link' => '', 'label' => $user->username, 'value' => $user->username, 'rels' => '', 'image' => $avatar['url'] ?: '');
            }
        }
        break;
    default:
        $results['rfc3514'] = '0x1';
        break;
}
// switch on action;
// We always do this
echo xoutput_from_array($results);
コード例 #20
0
 /**
  * show
  * Show the activity entry.
  */
 public function show()
 {
     // If user flags aren't enabled don't do anything
     if (!AmpConfig::get('userflags') || !$this->id) {
         return false;
     }
     $user = new User($this->user);
     $user->format();
     $libitem = new $this->object_type($this->object_id);
     $libitem->format();
     echo '<div>';
     $fdate = date('m/d/Y H:i:s', $this->activity_date);
     echo '<div class="shoutbox-date">';
     if ($user->f_avatar_mini) {
         echo '<a href="' . $user->link . '">' . $user->f_avatar_mini . '</a> ';
     }
     echo $fdate;
     echo '</div>';
     $descr = $user->f_link . ' ';
     switch ($this->action) {
         case 'shout':
             $descr .= T_('commented on');
             break;
         case 'upload':
             $descr .= T_('uploaded');
             break;
         case 'play':
             $descr .= T_('played');
             break;
         case 'userflag':
             $descr .= T_('favorited');
             break;
         case 'follow':
             $descr .= T_('started to follow');
             break;
         default:
             $descr .= T_('did something on');
             break;
     }
     $descr .= ' ' . $libitem->f_link;
     echo '<div>';
     echo $descr;
     if (Core::is_library_item($this->object_type)) {
         echo ' ';
         $libitem->display_art(10);
     }
     echo '</div>';
     echo '</div><br />';
 }
コード例 #21
0
ファイル: stream.class.php プロジェクト: cheese1/ampache
 /**
  * get_now_playing
  *
  * This returns the now playing information
  */
 public static function get_now_playing()
 {
     $sql = 'SELECT `session`.`agent`, `np`.* FROM `now_playing` AS `np` ';
     $sql .= 'LEFT JOIN `session` ON `session`.`id` = `np`.`id` ';
     if (AmpConfig::get('now_playing_per_user')) {
         $sql .= 'INNER JOIN ( ' . 'SELECT MAX(`insertion`) AS `max_insertion`, `user`, `id` ' . 'FROM `now_playing` ' . 'GROUP BY `user`' . ') `np2` ' . 'ON `np`.`user` = `np2`.`user` ' . 'AND `np`.`insertion` = `np2`.`max_insertion` ';
     }
     if (!Access::check('interface', '100')) {
         // We need to check only for users which have allowed view of personnal info
         $personal_info_id = Preference::id_from_name('allow_personal_info_now');
         if ($personal_info_id) {
             $current_user = $GLOBALS['user']->id;
             $sql .= "WHERE (`np`.`user` IN (SELECT `user` FROM `user_preference` WHERE ((`preference`='{$personal_info_id}' AND `value`='1') OR `user`='{$current_user}'))) ";
         }
     }
     $sql .= 'ORDER BY `np`.`expire` DESC';
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $type = $row['object_type'];
         $media = new $type($row['object_id']);
         $media->format();
         $client = new User($row['user']);
         $client->format();
         $results[] = array('media' => $media, 'client' => $client, 'agent' => $row['agent'], 'expire' => $row['expire']);
     }
     // end while
     return $results;
 }
コード例 #22
0
ファイル: read.php プロジェクト: rafalenden/KioCMS
// KioCMS - Kiofol Content Managment System
// modules/pm/read.php
$kio->addPath(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 = ' . $user->id)->fetch(PDO::FETCH_ASSOC);
// Message exists
if ($message) {
    $module->subcodename = 'read';
    $kio->addPath($message['subject'], 'pm/' . u1 . '/read/' . u3);
    // Sender/Recipient has id (is registered)
    if ($message['connector_id']) {
        $message['nickname'] = User::format($message['connector_id'], $message['nickname'], $message['group_id']);
    }
    // Message is unread
    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.html');
        $tpl->message = $message;
        $tpl->user = $user;
        $tpl->kio = $kio;
        echo $tpl->execute();
    } catch (Exception $e) {
        echo template_error($e);
    }
} else {
コード例 #23
0
ファイル: show_users.inc.php プロジェクト: bl00m/ampache
?>
      <th class="cel_action essential"><?php 
echo T_('Action');
?>
</th>
      <th class="cel_online"><?php 
echo T_('On-line');
?>
</th>
    </tr>
</thead>
<tbody>
<?php 
foreach ($object_ids as $user_id) {
    $libitem = new User($user_id);
    $libitem->format();
    $last_seen = $libitem->last_seen ? date("m\\/d\\/Y - H:i", $libitem->last_seen) : T_('Never');
    $create_date = $libitem->create_date ? date("m\\/d\\/Y - H:i", $libitem->create_date) : T_('Unknown');
    ?>
<tr class="<?php 
    echo UI::flip_class();
    ?>
" id="admin_user_<?php 
    echo $libitem->id;
    ?>
">
    <?php 
    require AmpConfig::get('prefix') . UI::find_template('show_user_row.inc.php');
    ?>
</tr>
<?php 
コード例 #24
0
ファイル: show_users.inc.php プロジェクト: axelsimon/ampache
?>
        <th class="cel_action"><?php 
echo T_('Action');
?>
</th>
      <th class="cel_online"><?php 
echo T_('On-line');
?>
</th>
    </tr>
</thead>
<tbody>
<?php 
foreach ($object_ids as $user_id) {
    $client = new User($user_id);
    $client->format();
    $last_seen = $client->last_seen ? date("m\\/d\\/Y - H:i", $client->last_seen) : T_('Never');
    $create_date = $client->create_date ? date("m\\/d\\/Y - H:i", $client->create_date) : T_('Unknown');
    ?>
<tr class="<?php 
    echo UI::flip_class();
    ?>
" id="admin_user_<?php 
    echo $client->id;
    ?>
">
    <?php 
    require AmpConfig::get('prefix') . '/templates/show_user_row.inc.php';
    ?>
</tr>
<?php 
コード例 #25
0
    public function getEntries()
    {
        global $sql;
        if (Kio::getConfig('order_by', 'guestbook') == 'DESC') {
            $x = $this->pager->items + 1 - $this->pager->offset;
            $y = '$x--;';
        } else {
            $x = $this->pager->offset;
            $y = '$x++;';
        }
        $entries = $sql->getCache('guestbook_' . $this->pager->current);
        if (empty($entries)) {
            $stmt = $sql->query('
				SELECT gb.id, gb.added, gb.author, gb.email, gb.website, gb.message, gb.author_id, gb.author_ip,
					u.nickname, u.group_id, u.avatar, u.signature
				FROM ' . DB_PREFIX . 'guestbook gb
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = gb.author_id
				ORDER BY gb.id ' . Kio::getConfig('order_by', 'guestbook') . '
				LIMIT ' . $this->pager->limit . '
				OFFSET ' . $this->pager->offset);
            if ($stmt->rowCount() > 0) {
                while ($row = $stmt->fetch()) {
                    eval($y);
                    $row['number'] = $x;
                    if ($row['author_id']) {
                        $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    }
                    $row['message'] = parse($row['message'], Kio::getConfig('parsers', 'guestbook'));
                    $row['signature'] = $row['signature'] ? parse($row['signature'], Kio::getConfig('parsers', 'guestbook')) : '';
                    $entries[] = $row;
                }
                $sql->putCacheContent('guestbook_' . $this->pager->current, $entries);
            } else {
                $this->note->info('Jeszcze nikt nie dodał żadnego wpisu.');
            }
        }
        return $entries;
    }
コード例 #26
0
ファイル: show_album.inc.php プロジェクト: cheese1/ampache
if (AmpConfig::get('show_played_times')) {
    ?>
<br />
<div style="display:inline;"><?php 
    echo T_('Played') . ' ' . $album->object_cnt . ' ' . T_('times');
    ?>
</div>
<?php 
}
?>

<?php 
$owner_id = $album->get_user_owner();
if (AmpConfig::get('sociable') && $owner_id > 0) {
    $owner = new User($owner_id);
    $owner->format();
    ?>
<div class="item_uploaded_by">
    <?php 
    echo T_('Uploaded by');
    ?>
 <?php 
    echo $owner->f_link;
    ?>
</div>
<?php 
}
?>

<div id="information_actions">
    <h3><?php 
コード例 #27
0
ファイル: image.php プロジェクト: rafalenden/KioCMS
        $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->description = $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.html');
        $tpl->cfg = $cfg;
コード例 #28
0
ファイル: graph.class.php プロジェクト: nioc/ampache
 public static function display_from_request()
 {
     if (!Access::check('interface', '50')) {
         UI::access_denied();
     } else {
         $user_id = $_REQUEST['user_id'];
         $object_type = $_REQUEST['object_type'];
         $object_id = $_REQUEST['object_id'];
         $end_date = $_REQUEST['end_date'] ? strtotime($_REQUEST['end_date']) : time();
         $f_end_date = date("Y-m-d H:i", $end_date);
         $start_date = $_REQUEST['start_date'] ? strtotime($_REQUEST['start_date']) : $end_date - 864000;
         $f_start_date = date("Y-m-d H:i", $start_date);
         $zoom = $_REQUEST['zoom'] ?: 'day';
         $gtypes = array();
         $gtypes[] = 'user_hits';
         if ($object_type == null || $object_type == 'song' || $object_type == 'video') {
             $gtypes[] = 'user_bandwidth';
         }
         if (!$user_id && !$object_id) {
             $gtypes[] = 'catalog_files';
             $gtypes[] = 'catalog_size';
         }
         $blink = '';
         if ($object_id) {
             if (Core::is_library_item($object_type)) {
                 $libitem = new $object_type($object_id);
                 $libitem->format();
                 if (isset($libitem->f_link)) {
                     $blink = $libitem->f_link;
                 }
             }
         } else {
             if ($user_id) {
                 $u = new User($user_id);
                 $u->format();
                 $blink = $u->f_link;
             }
         }
         require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
     }
 }
コード例 #29
0
 /**
  * display_home
  * This display the module in home page
  */
 public function display_home()
 {
     if (AmpConfig::get('userflags')) {
         $userflags = Userflag::get_latest(null, -1, $this->maxitems);
         $i = 0;
         echo '<div class="home_plugin"><table class="tabledata">';
         foreach ($userflags as $userflag) {
             $item = new $userflag['type']($userflag['id']);
             $item->format();
             $user = new User($userflag['user']);
             $user->format();
             if ($item->id) {
                 echo '<tr class="' . ($i % 2 == 0 ? 'even' : 'odd') . '"><td>';
                 echo '<div>';
                 echo '<div style="float: left;">';
                 echo '<span style="font-weight: bold;">' . $item->f_link . '</span> ';
                 echo '<span style="margin-right: 10px;">';
                 if (AmpConfig::get('directplay')) {
                     echo Ajax::button('?page=stream&action=directplay&object_type=' . $userflag['type'] . '&object_id=' . $userflag['id'], 'play', T_('Play'), 'play_' . $userflag['type'] . '_' . $userflag['id']);
                     if (Stream_Playlist::check_autoplay_append()) {
                         echo Ajax::button('?page=stream&action=directplay&object_type=' . $userflag['type'] . '&object_id=' . $userflag['id'] . '&append=true', 'play_add', T_('Play last'), 'addplay_' . $userflag['type'] . '_' . $userflag['id']);
                     }
                 }
                 echo Ajax::button('?action=basket&type=' . $userflag['type'] . '&id=' . $userflag['id'], 'add', T_('Add to temporary playlist'), 'play_full_' . $userflag['id']);
                 echo '</span>';
                 echo '</div>';
                 echo '<div style="float: right; opacity: 0.5;">' . T_('recommended by') . ' ' . $user->f_link . '</div>';
                 echo '</div><br />';
                 echo '<div style="margin-left: 30px;">';
                 echo '<div style="float: left; margin-right: 20px;">';
                 $thumb = UI::is_grid_view('album') ? 2 : 11;
                 $item->display_art($thumb);
                 echo '</div>';
                 echo '<div style="white-space: normal;">' . $item->get_description() . '</div>';
                 echo '</div>';
                 echo '</td></tr>';
                 $i++;
             }
         }
         echo '</table></div>';
     }
 }
コード例 #30
0
ファイル: pm.module.php プロジェクト: rafalenden/KioCMS
    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();
        }
    }