function upgrade_ran($v = false) { if (!$v) { $v = upgrade_version_num(); } return db_shift('select count(*) from sitellite_upgrade where num = ?', $v); }
function sitepoll_virtual_enable_comments(&$obj) { if ($obj->enable_comments == 'no') { return intl_get('Disabled'); } return db_shift('select count(*) from sitepoll_comment where poll = ?', $obj->id); }
function onSubmit($vals) { if (!$vals['group']) { $res = db_fetch_array('select distinct first_name, last_name, email_address, address_line1, address_line2, city, state, country, zip, company, job_title, phone_number, daytime_phone, evening_phone, mobile_phone, fax_number from sitellite_form_submission'); $name = 'all'; } else { $res = db_fetch_array('select distinct first_name, last_name, email_address, address_line1, address_line2, city, state, country, zip, company, job_title, phone_number, daytime_phone, evening_phone, mobile_phone, fax_number from sitellite_form_submission where form_type = ?', $vals['group']); $name = preg_replace('/[^a-z0-9]+/', '-', strtolower(db_shift('select name from sitellite_form_type where id = ?', $vals['group']))); } set_time_limit(0); header('Cache-control: private'); header('Content-type: text/plain'); header('Content-Disposition: attachment; filename=' . $name . '-' . date('Y-m-d') . '.csv'); echo "First Name,Last Name,Email Address,Address Line 1,Address Line 2,City,State,Country,Zip,Company,Job Title,Phone Number,Daytime Phone,Evening Phone,Mobile Phone,Fax Number\n"; foreach ($res as $row) { $r = (array) $row; foreach (array_keys($r) as $k) { $r[$k] = str_replace('"', '""', $r[$k]); if (strpos($r[$k], ',') !== false) { $r[$k] = '"' . $r[$k] . '"'; } } echo str_replace(array("\r", "\n"), array('\\r', '\\n'), join(',', $r)) . "\n"; } exit; }
function SitepresenterEditSlideForm() { parent::MailForm(); $this->parseSettings('inc/app/sitepresenter/forms/edit/slide/settings.php'); page_add_script(' function cms_cancel (f) { if (arguments.length == 0) { window.location.href = "/index/cms-app"; } else { if (f.elements["_return"] && f.elements["_return"].value.length > 0) { window.location.href = f.elements["_return"].value; } else { window.location.href = "/index/sitepresenter-app"; } } return false; } '); $this->widgets['submit_button']->buttons[1]->extra = 'onclick="return cms_cancel (this.form)"'; global $cgi; page_title(intl_get('Adding Slide to Presentation') . ': ' . db_shift('select title from sitepresenter_presentation where id = ?', $cgi->presentation)); $res = db_single('select * from sitepresenter_slide where id = ?', $cgi->id); foreach (get_object_vars($res) as $k => $v) { $this->widgets[$k]->setValue($v); } }
function EntryAddForm() { parent::MailForm(); $this->parseSettings('inc/app/timetracker/forms/entry/add/settings.php'); $res = db_fetch('select username, firstname, lastname from sitellite_user order by lastname asc'); if (!$res) { $res = array(); } elseif (is_object($res)) { $res = array($res); } $users = array(); foreach ($res as $row) { if (!empty($row->lastname)) { $users[$row->username] = $row->lastname; if (!empty($row->firstname)) { $users[$row->username] .= ', ' . $row->firstname; } $users[$row->username] .= ' (' . $row->username . ')'; } else { $users[$row->username] = $row->username; } } $this->widgets['users']->setValues($users); $this->widgets['users']->setDefault(session_username()); $this->widgets['users']->addRule('not empty', 'You must select at least one user.'); $this->widgets['started']->setDefault(date('Y-m-d H:i:s')); $this->widgets['ended']->setDefault(date('Y-m-d H:i:s')); global $cgi; $this->widgets['proj_name']->setValue(db_shift('select name from timetracker_project where id = ?', $cgi->project)); $this->widgets['submit_button']->buttons[1]->extra = 'onclick="history.go (-1); return false"'; }
function SiteblogEditForm() { parent::MailForm(); global $cgi; $refer = $_SERVER['HTTP_REFERER']; $this->parseSettings('inc/app/siteblog/forms/edit/settings.php'); $this->widgets['refer']->setValue($refer); //if add is true, we're creating a blog post, otherwise we're editing a blog post $add = isset($cgi->_key) && !empty($cgi->_key) ? false : true; $this->widgets['status']->setValues(array('Live', 'Not Live')); $cats = db_pairs('select id, title from siteblog_category where status = "on"'); if ($add) { page_title('Adding a Blog Post'); $this->widgets['author']->setValue(session_username()); unset($this->widgets['icategory']); $this->widgets['category']->setValues($cats); } else { loader_import('cms.Versioning.Rex'); $rex = new Rex('siteblog_post'); $document = $rex->getCurrent($cgi->_key); page_title('Editing a Blog Post'); //populate fields $this->widgets['subject']->setValue($document->subject); $this->widgets['author']->setValue($document->author); $this->widgets['status']->setValue($document->status); unset($this->widgets['category']); $catname = db_shift('select title from siteblog_category where id = ?', $document->category); $this->widgets['icategory']->setValue($catname); $this->widgets['oldcat']->setValue($document->category); $this->widgets['body']->setValue($document->body); } }
function digger_filter_user($user) { $pub = db_shift('select public from sitellite_user where username = ?', $user); if ($pub == 'yes') { return '<a href="' . site_prefix() . '/index/sitemember-profile-action/user.' . $user . '">' . $user . '</a>'; } return $user; }
function onSubmit($vals) { $number = db_shift('select number from sitepresenter_slide where presentation = ? order by number desc', $vals['presentation']); $number++; if ($number == 0) { $number = 1; } db_execute('insert into sitepresenter_slide (id, title, presentation, number, body) values (null, ?, ?, ?, ?)', $vals['title'], $vals['presentation'], $number, $vals['body']); header('Location: ' . site_prefix() . '/index/sitepresenter-slides-action?id=' . $vals['presentation']); exit; }
function sitefaq_facet_assigned_to() { $res = db_shift_array('select distinct assigned_to from sitefaq_submission order by assigned_to asc'); $ret = array(); foreach ($res as $a) { if (empty($a)) { continue; $ret[''] = intl_get('None'); } else { $ret[$a] = db_shift('select concat(lastname, ", ", firstname, " (", username, ")") from sitellite_user where username = ?', $a); } } return $ret; }
function onSubmit($vals) { loader_import('siteforum.Post'); loader_import('siteforum.Filters'); loader_import('siteforum.Topic'); $p = new SiteForum_Post(); if (!session_admin()) { $notice = 'no'; } else { if ($vals['notice'] == 'Make this post a notice.') { $notice = 'yes'; } else { $notice = 'no'; } } $t = new SiteForum_Topic(); $topic = $t->get($vals['topic']); if (!($res = $p->add(array('user_id' => session_username(), 'topic_id' => $vals['topic'], 'post_id' => $vals['post'], 'ts' => date('Y-m-d H:i:s'), 'subject' => $vals['subject'], 'body' => $vals['body'], 'sig' => db_shift('select sig from sitellite_user where username = ?', session_username()), 'notice' => $notice, 'sitellite_access' => $topic->sitellite_access, 'sitellite_status' => $topic->sitellite_status)))) { page_title(intl_get('Database Error')); echo '<p>' . intl_get('An error occurred. Please try again later.') . '</p>'; echo '<p>' . intl_get('Error Message') . ': ' . $p->error . '</p>'; return; } $vals['id'] = $res; if (!empty($vals['post'])) { $p->touch($vals['post']); } if ($vals['subscribe'] == 'Subscribe me to this forum thread.') { if (!$vals['post']) { $vals['post'] = $res; } db_execute('insert into siteforum_subscribe (id, post_id, user_id) values (null, ?, ?)', $vals['post'], session_username()); } $ae = appconf('admin_email'); if ($ae) { @mail($ae, intl_get('Forum Posting Notice'), template_simple('post_email.spt', $vals), 'From: ' . appconf('forum_name') . '@' . site_domain()); } $exempt = explode(',', $ae); $res = db_fetch_array('select distinct u.email, u.username from sitellite_user u, siteforum_subscribe s where s.user_id = u.username and s.post_id = ?', $vals['post']); foreach ($res as $row) { if (in_array($row->email, $exempt)) { continue; } $vals['user_id'] = $row->username; @mail($row->email, intl_get('Forum Posting Notice'), template_simple('post_email_subscriber.spt', $vals), 'From: ' . appconf('forum_name') . '@' . site_domain()); } page_title(intl_get('Message Posted')); echo template_simple('post_submitted.spt', $vals); }
function digger_has_voted($id) { if (!session_valid()) { return false; } // can't vote on own stories if (db_shift('select count(*) from digger_linkstory where id = ? and user = ?', $id, session_username())) { return true; } // voted already if (db_shift('select count(*) from digger_vote where story = ? and user = ?', $id, session_username())) { return true; } return false; }
function getList($user = false) { if (!$user) { $user = session_username(); } $res = db_fetch('select * from sitellite_msg_category where user = ? order by name asc', $user); if (!$res) { $this->error = db_error(); $res = array(); } elseif (is_object($res)) { $res = array($res); } foreach (array_keys($res) as $k) { $res[$k]->count = db_shift('select count(*) from sitellite_msg_recipient where status != "trash" and type = "user" and user = ? and category = ?', $user, $res[$k]->name); } return $res; }
function onSubmit($vals) { // 1. add author if necessary if (!db_shift('select * from sitellite_news_author where name = ?', $vals['author'])) { db_execute('insert into sitellite_news_author (name) values (?)', $vals['author']); } // 2. submit story as 'draft' loader_import('cms.Versioning.Rex'); $rex = new Rex('sitellite_news'); $res = $rex->create(array('title' => $vals['title'], 'author' => $vals['author'], 'category' => $vals['category'], 'summary' => $vals['summary'], 'body' => $vals['body'], 'date' => date('Y-m-d'), 'sitellite_status' => 'draft', 'sitellite_access' => 'public'), 'Story submission.'); $vals['id'] = $res; // 3. email notification @mail(appconf('submissions'), 'News Submission Notice', template_simple('submission_email.spt', $vals)); // 4. thank you screen page_title(intl_get('Thank You!')); echo template_simple('submissions.spt'); }
function onSubmit($vals) { if (!db_shift('select count(*) from sitellite_homepage where user = ?', session_username())) { if (!db_execute('insert into sitellite_homepage (user, title, template, body) values (?, ?, ?, ?)', session_username(), $vals['title'], $vals['template'], $vals['body'])) { page_title(intl_get('An Error Occurred')); echo '<p>' . intl_get('Error') . ': ' . db_error() . '</p>'; return; } } else { if (!db_execute('update sitellite_homepage set title = ?, template = ?, body = ? where user = ?', $vals['title'], $vals['template'], $vals['body'], session_username())) { page_title(intl_get('An Error Occurred')); echo '<p>' . intl_get('Error') . ': ' . db_error() . '</p>'; return; } } page_title(intl_get('Changes Saved')); echo '<p><a href="' . site_prefix() . '/index/sitemember-app">' . intl_get('Return to member home.') . '</a></p>'; }
function onSubmit($vals) { $header = 'Location: ' . site_prefix() . '/index/siteblog-view-action/head.on/complex.on'; if ($vals['author'] != '0') { $header .= '/author.' . $vals['author']; } if ($vals['year'] != 0) { $header .= '/year.' . $vals['year']; } if ($vals['month'] != 0) { $header .= '/month.' . $vals['month']; } if ($vals['category'] != 0) { $header .= '/category.' . $vals['category']; $header .= '/title.' . siteblog_filter_link_title(db_shift('select title from siteblog_category where id = ?', $vals['category'])); } header($header); exit; }
function vote($score, $id) { $ip = $_SERVER['REMOTE_ADDR']; $user = session_username(); if (!$user) { $user = '******'; } if ($score == 'yes') { db_execute('UPDATE digger_linkstory SET score = score + 1 WHERE id = ?', $id); db_execute('INSERT INTO digger_vote (id, story, score, user, ip, votetime) VALUES (null, ?, 1, ?, ?, NOW())', $id, $user, $ip); } else { db_execute('UPDATE digger_linkstory SET score=score-1 WHERE id = ?', $id); db_execute('INSERT INTO digger_vote (id, story, score, user, ip, votetime) VALUES (null, ?, -1, ?, ?, NOW())', $id, $user, $ip); $score = db_shift('select score from digger_linkstory where id = ?', $id); if ($score <= appconf('ban_threshold')) { db_execute('update digger_linkstory set status = "disabled" where id = ?', $id); } } return true; }
function onSubmit($vals) { $ak = appconf('akismet_key'); if ($ak) { loader_import('siteblog.Akismet'); $comment = array('author' => $vals['name'], 'email' => $vals['email'], 'website' => $vals['url'], 'body' => $vals['body'], 'permalink' => site_url() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT']); $akismet = new Akismet(site_url(), $ak, $comment); if (!$akismet->errorsExist()) { // no errors if ($akismet->isSpam()) { // akismet says spam $title = db_shift('select subject from siteblog_post where id = ?', $vals['post']); db_execute('insert into siteblog_akismet values (null, ?, now(), ?, ?, ?, ?, ?, ?)', $vals['post'], $comment['author'], $comment['email'], $comment['website'], $comment['user_ip'], $comment['user_agent'], $comment['body']); header('Location: ' . site_prefix() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title)); exit; } } } if (!empty($vals['post'])) { $res = db_execute('insert into siteblog_comment (id, child_of_post, body, date, author, email, url, ip) values (null, ?, ?, now(), ?, ?, ?, ?)', $vals['post'], $vals['body'], $vals['name'], $vals['email'], $vals['url'], $_SERVER['REMOTE_ADDR']); if (!$res) { die(db_error()); } $id = db_lastid(); } else { $res = db_execute('update siteblog_comment set body = ?, author = ?, email = ?, url = ? where id = ?', $vals['body'], $vals['name'], $vals['email'], $vals['url'], $vals['_key']); if (!$res) { die(db_error()); } $id = $vals['_key']; $vals['post'] = db_shift('select child_of_post from siteblog_comment where id = ?', $vals['_key']); } $title = db_shift('select subject from siteblog_post where id = ?', $vals['post']); header('Location: ' . site_prefix() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title) . '#siteblog-comment-' . $id); exit; }
<?php // your app begins here loader_import('siteforum.Topic'); loader_import('siteforum.Filters'); $t = new SiteForum_Topic(); $t->orderBy('name asc'); $list = $t->getTopics(); /*if (loader_import ('sitetracker.SiteTracker')) { $guests = SiteTracker::get ( array ( 'api_call' => 'num_visitors_online', 'session_lifetime' => 15, ) ); } else {*/ $guests = false; //} page_title(appconf('forum_name')); echo template_simple('topic_list.spt', array('list' => $list, 'sitesearch' => @file_exists('inc/app/sitesearch/data/sitesearch.pid'), 'users' => db_shift('select count(*) from sitellite_user'), 'active' => db_shift('select count(*) from sitellite_user where session_id is not null and expires >= ?', date('Y-m-d H:i:s', time() - 3600)), 'posts' => db_shift('select count(*) from siteforum_post'), 'today' => db_shift('select count(*) from siteforum_post where ts >= ?', date('Y-m-d 00:00:00')), 'week' => db_shift('select count(*) from siteforum_post where ts >= ?', date('Y-m-d 00:00:00', time() - 604800)), 'guests' => $guests));
} $limit = appconf('limit'); $q = db_query('SELECT * FROM digger_linkstory WHERE status = "enabled" ' . $cat . ' ORDER BY posted_on desc, score desc'); if ($q->execute()) { $total = $q->rows(); $res = $q->fetch($cgi->offset, $limit); $q->free(); } else { die($q->error()); } // has voted? foreach (array_keys($res) as $k) { if (digger_has_voted($res[$k]->id)) { $res[$k]->voted = 'style="display: none"'; } } // pager loader_import('saf.GUI.Pager'); $pg = new Pager($cgi->offset, $limit, $total); $pg->setUrl(site_prefix() . '/index/digger-app?category=' . $cgi->category); $pg->getInfo(); // output if (!empty($cgi->category)) { page_title(appconf('digger_title') . ' - ' . db_shift('select category from digger_category where id = ?', $cgi->category)); } else { page_title(appconf('digger_title')); } template_simple_register('pager', $pg); echo template_simple('index.spt', array('category' => $cgi->category, 'results' => $res, 'banned_score' => appconf('ban_threshold')));
function petition_filter_signatures(&$obj) { return '<a href="' . site_prefix() . '/index/petition-signatures-action/id.' . $obj->id . '">' . db_shift('select count(*) from petition_signature where petition_id = ?', $obj->id) . '</a>'; }
<ul> <?php loader_import('siteblog.Filters'); foreach (db_pairs('select id, title from siteblog_category order by title asc') as $id => $title) { $count = db_shift('select count(*) from siteblog_post where category = ?', $id); echo '<li><a href="' . site_prefix() . '/index/siteblog-topic-action/id.' . $id . '/title.' . siteblog_filter_link_title($title) . '">' . $title . ' (' . $count . ')</a></li>'; } ?> </ul>
<?php if (!session_valid()) { header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; } if (!session_admin()) { global $cgi; $user = db_shift('select user_id from siteforum_post where id = ?', $cgi->id); if ($user != session_username()) { header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; } } class SiteforumPostEditForm extends MailForm { function SiteforumPostEditForm() { parent::MailForm(); page_title(intl_get('Edit a Post')); $this->parseSettings('inc/app/siteforum/forms/post/edit/settings.php'); page_add_script(' function siteforum_preview (f) { t = f.target; a = f.action; f.target = "_blank"; f.action = "' . site_prefix() . '/index/siteforum-post-preview-action"; f.submit (); f.target = t;
die($q->error); } $total = $q->rows(); $res = $q->fetch($cgi->offset, appconf('limit')); $q->free(); } else { $q = db_query('select * from siteblog_post where category = ? order by created desc'); if (!$q->execute($parameters['id'])) { die($q->error); } $total = $q->rows(); $res = $q->fetch($cgi->offset, appconf('limit')); $q->free(); } $res =& siteblog_translate($res); $pg = new Pager($cgi->offset, appconf('limit'), $total); $pg->setUrl(site_prefix() . '/index/siteblog-topic-action/id.' . $parameters['id'] . '/title.' . $parameters['title']); $pg->getInfo(); template_simple_register('pager', $pg); foreach (array_keys($res) as $k) { $res[$k]->comments = db_shift('select count(id) from siteblog_comment where child_of_post = ?', $res[$k]->id); $res[$k]->comments_on = true; $res[$k]->category_name = siteblog_filter_category($res[$k]->category); if ($res[$k]->status == 'visible') { $res[$k]->sitellite_status = 'approved'; } else { $res[$k]->sitellite_status = 'draft'; } } page_add_style(site_prefix() . '/inc/app/siteblog/html/post.css'); echo template_simple('posts.spt', array('post' => $res));
function count_all() { return db_shift('select count(*) from sitellite_autosave where user_id = ?', session_username()); }
$query .= ' ORDER BY created DESC '; if (isset($cgi->limit)) { $query .= ' limit ' . $cgi->limit; } $res = db_fetch_array($query); } else { $catname = ''; $res = db_fetch_array('select * from siteblog_post order by created desc limit 10'); } foreach ($res as $k => $r) { if ($maxlen) { if (strlen($res[$k]->body) > $maxlen) { $res[$k]->body = substr($res[$k]->body, 0, $maxlen) . '...'; } } if ($properties[$r->category]['comments'] == 'on') { $res[$k]->comments = db_shift('select count(id) from siteblog_comment where child_of_post = ?', $r->id); $res[$k]->comments_on = true; } else { $res[$k]->comments_on = false; } if ($properties[$r->category]['poster_visible'] == 'yes') { $res[$k]->show_author = true; } $res[$k]->category = db_shift('select title from siteblog_category where id = ?', $r->category); } $res =& siteblog_translate($res); header('Content-Type: text/xml'); echo template_simple('rss_post.spt', array('category' => $catname, 'post' => $res, 'category_id' => $cgi->category, 'rss_date' => date('Y-m-d\\TH:i:s'))); exit; //echo template_simple ($template, array ('post' => $res));
* - modify: Ordinary modifications (source and store) * - replace: A change was approved, overwriting the live version * - republish: A change was made as a draft, requiring approval * - update: Update to a draft that was republished */ if ($parameters['collection'] != 'sitefaq_submission') { return; } switch ($parameters['action']) { case 'modify': /* For this collection, since it doesn't support versioning, * the action will always be 'modify'. */ if ($parameters['data']['sitellite_status'] == 'approved') { if (conf('App', 'sitefaq', 'user_anonymity')) { $parameters['data']['email'] = db_shift('select email from sitefaq_submission where id = ?', $parameters['data']['id']); } if (!empty($parameters['data']['email'])) { // reply to user @mail($parameters['data']['email'], intl_get('FAQ Response'), template_simple('email_answer.spt', $parameters['data']), 'From: faq@' . str_replace('www.', '', site_domain())); } if (conf('App', 'sitefaq', 'user_anonymity')) { // erase user's contact info loader_import('cms.Versioning.Rex'); $rex = new Rex('sitefaq_submission'); $rex->modify($parameters['data'][$rex->key], array('name' => '', 'email' => '', 'url' => '', 'ip' => '', 'member_id' => '')); } } break; case 'replace': break;
<?php $ak = appconf('akismet_key'); if (!$ak) { header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } loader_import('siteblog.Filters'); $c = db_single('select * from siteblog_comment where id = ?', $parameters['id']); db_execute('delete from siteblog_comment where id = ?', $parameters['id']); $title = db_shift('select subject from siteblog_post where id = ?', $vals['post']); $comment = array('author' => $c->name, 'email' => $c->email, 'website' => $c->url, 'body' => $c->body, 'permalink' => site_url() . '/index/siteblog-post-action/id.' . $c->post_id . '/title.' . siteblog_filter_link_title($title), 'user_ip' => $c->ip, 'user_agent' => ''); loader_import('siteblog.Akismet'); $akismet = new Akismet(site_url(), $ak, $comment); if (!$akismet->errorsExist()) { // no errors $akismet->submitSpam(); } header('Location: ' . $_SERVER['HTTP_REFERER']); exit;
if (!$res) { $res = array(); } elseif (is_object($res)) { $res = array($res); } foreach ($res as $key => $row) { $res[$key]->total = db_shift('select sum(e.duration) from timetracker_entry e, timetracker_user_entry u where u.entry_id = e.id and u.user_id = ? and e.project_id = ?', $row->username, $parameters['project']); $res[$key]->month = db_shift('select sum(e.duration) from timetracker_entry e, timetracker_user_entry u where u.entry_id = e.id and u.user_id = ? and e.started between ? and ? and e.project_id = ?', $row->username, $y . '-' . $m . '-01 00:00:00', $y . '-' . $m . '-' . $t . ' 23:59:59', $parameters['project']); $res[$key]->weeks = array(); foreach ($weeks as $k => $week) { $sum = db_shift('select sum(e.duration) from timetracker_entry e, timetracker_user_entry u where u.entry_id = e.id and u.user_id = ? and e.started between ? and ? and e.project_id = ?', $row->username, $y . '-' . $m . '-' . $week['start'] . ' 00:00:00', $y . '-' . $m . '-' . $week['end'] . ' 23:59:59', $parameters['project']); $res[$key]->weeks[] = $sum; $weeks[$k]['total'] += $sum; } $data['month_total'] += $res[$key]->month; $data['grand_total'] += $res[$key]->total; } $data['employees'] = $res; $data['weeks'] = $weeks; //echo '<pre>'; //print_r ($data); //echo '</pre>'; //exit; loader_import('timetracker.Filters'); page_title('TimeTracker - ' . $data['project_name'] . ' (' . intl_get('Project ID') . ': ' . $data['project'] . ')');
/** * Checks whether a lock exists on the current resource, owned * by another user than the current one. */ function exists($resource, $key) { return db_shift('select id from sitellite_lock where user != ? and resource = ? and resource_id = ? and expires > now()', session_username(), $resource, $key); }
function getLatest($limit = 5, $topic = false) { if (session_admin()) { $perms = session_allowed_sql(); } else { $perms = session_approved_sql(); } if ($topic) { $list = db_fetch_array('select id, topic_id, user_id, ts, subject from siteforum_post where topic_id = ? and ' . $perms . ' order by ts desc limit ' . $limit, $topic); } else { $list = db_fetch_array('select id, topic_id, user_id, ts, subject from siteforum_post where ' . $perms . ' order by ts desc limit ' . $limit); } if (!$list) { return array(); } loader_import('siteforum.Topic'); $t = new SiteForum_Topic(); foreach (array_keys($list) as $k) { $list[$k]->topic_name = $t->getTitle($list[$k]->topic_id); $list[$k]->user_public = db_shift('select public from sitellite_user where username = ?', $list[$k]->user_id); } return $list; }