protected function Upload($dir, $files) { global $lang; $sum = 0; foreach ($files as $key => $val) { $sum += $_FILES[$val]['size']; } if ($sum <= 2097152) { $rel_dir = 'Uploads/'; $make_dir = FALSE; if (get_setting('ftp', 'use_ftp') || intval(get_setting('ftp', 'use_ftp')) == 1) { if ($conn_id = ftp_connect(get_setting('ftp', 'server'))) { if (@ftp_login($conn_id, get_setting('ftp', 'username'), get_setting('ftp', 'password'))) { @ftp_mkdir($conn_id, $rel_dir . $dir); @ftp_chmod($conn_id, 0777, $rel_dir . $dir); $make_dir = TRUE; } } } else { if (@mkdir($rel_dir . $dir)) { $make_dir = TRUE; } } if ($make_dir) { foreach ($files as $key => $file) { @move_uploaded_file($_FILES[$file]['tmp_name'], $rel_dir . $dir . '/' . $_FILES[$file]['name']); } } } else { return SetError::Set($lang['L_ERRORFILESTOOBIG']); } return TRUE; }
public function __construct($session) { global $lang; global $settings; $this->lang = $lang; $request = $_GET; $this->session = $session; $this->settings = $settings; if (!$request['id']) { return SetError::Set($this->lang['L_INVALIDFORUM']); } else { $id = intval($request['id']); } /* Pagination */ $limit = isset($_GET['limit']) ? intval($_GET['limit']) : NULL; $start = isset($_GET['start']) ? intval($_GET['start']) : NULL; $extra = !is_null($limit) && !is_null($start) ? "LIMIT " . $start . ", " . $limit : "LIMIT " . $this->settings['maxthreads']; $second_sort = isset($_GET['sort']) ? $_GET['sort'] : "created"; $order = isset($_GET['order']) && ($_GET['order'] == 'ASC' || $_GET['order'] == 'DESC') ? $_GET['order'] : "DESC"; $timeprune = isset($_GET['daysprune']) && is_numeric($_GET['daysprune']) ? mktime(0, 0, 0, date("m"), -$_GET['daysprune'], date("Y")) : 0; /* Query */ $dba = DBA::Open(); $this->announcements = $dba->Query("SELECT * FROM " . POSTS . " WHERE parent_id = {$id} AND row_type = 2 AND row_status > 2 ORDER BY row_status DESC, created DESC")->GetIterator(); //$this->threads = $dba->Query("SELECT p.name as name, p.poster_id as poster_id, p.row_right as row_right, p.row_left as row_left, p.poster_name as poster_name, p.views as views, p.last_reply as last_reply, p.created as created, p.reply_uid as reply_uid, p.reply_uname as reply_uname, p.poster_name as poster_name, p.id as id, p.poll as poll, p.row_status as row_status, p.attach as attach, (p.row_right-p.row_left-1)/2 as num_replies //, SUM(r.rating) as rating_sum, COUNT(r.thread_id) as num_rates FROM ". POSTS ." p, ". RATINGS ." r WHERE r.thread_id = p.id AND p.parent_id = $id AND p.row_type = 2 AND p.row_status < 3 AND p.created > $timeprune ORDER BY p.row_status DESC, $second_sort $order $extra")->GetIterator(); $this->threads = $dba->Query("SELECT *, (row_right-row_left-1)/2 as num_replies FROM " . POSTS . " WHERE parent_id = {$id} AND row_type = 2 AND row_status < 3 AND created > {$timeprune} ORDER BY row_status DESC, {$second_sort} {$order} {$extra}")->GetIterator(); $this->ratings = array(); foreach ($dba->Query("SELECT * FROM " . RATINGS) as $rating) { @($this->ratings[$rating['thread_id']]['rating'] += $rating['rating']); @($this->ratings[$rating['thread_id']]['count'] += 1); } // (SELECT SUM(rating) FROM ". RATINGS ." WHERE thread_id = threadid) as rating_sum, (SELECT COUNT(*) FROM ". RATINGS ." WHERE thread_id = threadid) as num_rates if ($this->announcements->Valid()) { $this->current = $this->announcements; } else { $this->current = $this->threads; } }
private function GetUsers($name) { /* Get the user(s) */ $users = $this->exact == FALSE ? $this->dba->Query("SELECT name FROM " . USERS . " WHERE lower(name) LIKE lower('" . $this->dba->Quote($name) . "%') GROUP BY name ORDER BY name DESC") : $this->dba->GetRow("SELECT name FROM " . USERS . " WHERE name = '" . $name . "'"); if (method_exists($users, 'NumRows')) { $this->user_count = $users->NumRows(); } else { if (is_array($users) && array_key_exists('name', $users)) { $this->user_count = 1; $users = array($users); } else { global $lang; return SetError::Set($lang['L_USERDOESNTEXIST']); } } return $users; }