Exemplo n.º 1
0
 function _eventsInRange($start, $end = false, $cat = '', $aud = '', $user = '', $fields = '*', $limit = false)
 {
     if (session_admin()) {
         $append = session_allowed_sql();
     } else {
         $append = session_approved_sql();
     }
     if (!empty($user)) {
         $usr = '******' . db_quote($user);
     } else {
         $usr = '******';
     }
     if (!empty($cat)) {
         $cat = ' and category = ' . db_quote($cat);
     } else {
         $cat = ' ';
     }
     if (!empty($aud)) {
         $aud = ' and audience like ' . db_quote('%' . $aud . '%');
     } else {
         $aud = ' ';
     }
     if ($limit !== false) {
         $lim = ' limit ' . $limit;
     } else {
         $lim = ' ';
     }
     $start = db_quote($start);
     $sql = 'select ' . $fields . ' from siteevent_event where (';
     if ($end) {
         $end = db_quote($end);
         $sql .= sprintf('(recurring = "no" and date >= %s and date <= %s and until_date = "0000-00-00") or ', $start, $end);
         $sql .= sprintf('(recurring != "no" and date <= %s and until_date = "0000-00-00") or ', $end);
         $sql .= sprintf('(date <= %s and until_date >= %s)', $end, $start);
     } else {
         $sql .= sprintf('(recurring = "no" and date >= %s and until_date = "0000-00-00") or ', $start);
         // not recurring, starts after $start
         $sql .= sprintf('(recurring != "no" and until_date = "0000-00-00") or ');
         // no end recurring date
         $sql .= sprintf('(until_date >= %s)', $start);
         // ends after $start
     }
     $sql .= ') ' . $usr . $cat . $aud . ' and ' . $append . ' order by date asc, time asc, until_date asc, until_time asc' . $lim;
     return db_fetch_array($sql);
 }
Exemplo n.º 2
0
    function getTopics()
    {
        if (session_admin()) {
            $perms = session_allowed_sql();
        } else {
            $perms = session_approved_sql();
        }
        $list = db_fetch_array('select * from siteforum_topic where ' . $perms . ' order by
name asc');
        foreach (array_keys($list) as $k) {
            $list[$k]->threads = db_shift('select count(*) from siteforum_post where topic_id = ? and post_id = ""', $list[$k]->id);
            $list[$k]->posts = db_shift('select count(*) from siteforum_post where topic_id = ?', $list[$k]->id);
            $obj = db_single('select ts, user_id, id from siteforum_post where topic_id = ? order by ts desc limit 1', $list[$k]->id);
            $list[$k]->last_post = $obj->ts;
            $list[$k]->last_post_user = $obj->user_id;
            $list[$k]->last_post_id = $obj->id;
            $list[$k]->last_post_user_public = db_shift('select public from sitellite_user where username = ?', $obj->user_id);
        }
        return $list;
    }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
<?php

if (session_admin()) {
    $acl = session_allowed_sql();
} else {
    $acl = session_approved_sql();
}
$res = db_fetch_array('select name, display_title, extension, description from sitellite_filesystem where path = ? and ' . $acl . ' order by name asc', $parameters['path']);
$valid = appconf('valid');
foreach (array_keys($res) as $k) {
    if (!in_array(strtolower($res[$k]->extension), $valid)) {
        unset($res[$k]);
    }
}
if ($parameters['title']) {
    if ($box['context'] == 'action') {
        page_title($parameters['title']);
    } else {
        echo '<h2>' . $parameters['title'] . '</h2>';
    }
}
page_add_script(site_prefix() . '/js/rollover.js');
template_simple_register('results', $res);
template_simple_register('first', array_shift($res));
echo template_simple('slideshow.spt', array('path' => $parameters['path'], 'total' => count($res) + 1, 'desc' => $parameters['descriptions'], 'delay' => $parameters['delay']));
Exemplo n.º 5
0
<?php

if (session_admin()) {
    $allowed = session_allowed_sql();
} else {
    $allowed = session_approved_sql();
}
$pres = db_single('select * from sitepresenter_presentation where id = ? and ' . $allowed, $parameters['id']);
if (!$pres) {
    header('Location: ' . site_prefix() . '/index/sitepresenter-app');
    exit;
}
loader_import('saf.Date');
$pres->date = Date::format($pres->ts, 'Ymd');
$pres->fmdate = Date::format($pres->ts, 'F j, Y');
$res = db_single('select concat(firstname, " ", lastname) as author, company from sitellite_user where username = ?', $pres->sitellite_owner);
$pres->author = $res->author;
$pres->company = $res->company;
$doms = explode('.', site_domain());
$pres->domain = array_pop($doms);
$pres->domain = '.' . $pres->domain;
$pres->domain = array_pop($doms) . $pres->domain;
$pres->slides = db_fetch_array('select * from sitepresenter_slide where presentation = ? order by number asc', $parameters['id']);
db_execute('insert into sitepresenter_view (presentation, ts, ip) values (?, now(), ?)', $parameters['id'], $_SERVER['REMOTE_ADDR']);
if (isset($parameters['theme']) && !strpos($parameters['theme'], '..') && @is_dir('inc/app/sitepresenter/themes/' . $parameters['theme'])) {
    $pres->theme = $parameters['theme'];
}
echo template_simple('presentation.spt', $pres);
exit;
Exemplo n.º 6
0
<?php

if (session_admin()) {
    $clause = session_allowed_sql();
} else {
    $clause = session_approved_sql();
}
$list = db_fetch_array('select
		id, title, year(date_added) as year, date_added
	from
		sitepoll_poll
	where ' . $clause . '
	order by
		date_added desc');
loader_import('sitepoll.Poll');
$p = new SitePoll();
$p->usePermissions = true;
$p->multilingual = true;
$p->orderBy('date_added desc');
$list = $p->find(array());
foreach ($list as $k => $v) {
    $list[$k]->year = substr($v->date_added, 0, 4);
}
$years = array();
foreach ($list as $k => $v) {
    if (!is_array($years[$v->year])) {
        $years[$v->year] = array($v);
    } else {
        $years[$v->year][] = $v;
    }
}
Exemplo n.º 7
0
 /**
  * Returns a single object with the specified $id.
  *
  * @access public
  * @param mixed
  * @return object
  */
 function &get($id)
 {
     if ($this->usePermissions) {
         if (session_admin()) {
             $and = ' and ' . session_allowed_sql();
         } else {
             $and = ' and ' . session_approved_sql();
         }
     } else {
         $and = '';
     }
     $res = db_fetch('SELECT * FROM ' . $this->table . ' WHERE ' . $this->pkey . ' = ?' . $and . $this->_end(), $id);
     if (!$res) {
         $this->error = db_error();
         return false;
     }
     if ($this->multilingual && intl_lang() != intl_default_lang()) {
         loader_import('multilingual.Translation');
         $tr = new Translation($this->table, intl_lang());
         if (session_admin()) {
             $translated = $tr->get($res->{$this->pkey});
         } else {
             $translated = $tr->get($res->{$this->pkey}, true);
         }
         if ($translated) {
             foreach ($translated->data as $key => $value) {
                 $res->{$key} = $value;
             }
         }
     }
     return $res;
 }