public function home() { global $user; $v = $this->__(w('alias filename ext')); if (!f($v['alias']) || !f($v['filename'])) { _fatal(); } $sql = 'SELECT tree_id FROM _tree WHERE tree_alias = ?'; if (!($tree = _fieldrow(sql_filter($sql, $v['alias'])))) { _fatal(); } $sql = 'SELECT * FROM _downloads WHERE download_alias = ? AND download_tree = ?'; if (!($download = _fieldrow(sql_filter($sql, $v['filename'], $tree['tree_id'])))) { _fatal(); } if ($download['download_login']) { _login(); } $sql = 'UPDATE _downloads SET download_count = download_count + 1 WHERE download_id = ?'; _sql(sql_filter($sql, $download['download_id'])); $filepath = LIB . 'fetch/' . _filename($download['download_id'], $download['download_extension']); return; }
function home() { global $user, $style; // /get/$1/$2.$3 $v = $this->__(array('alias', 'filename', 'ext')); if (empty($v['alias']) || empty($v['filename'])) { _fatal(); } $sql = "SELECT tree_id\n\t\t\tFROM _tree\n\t\t\tWHERE tree_alias = '" . $this->_escape($v['alias']) . "'"; if (!($tree = $this->_fieldrow($sql))) { _fatal(); } $sql = "SELECT *\n\t\t\tFROM _downloads\n\t\t\tWHERE download_alias = '" . $this->_escape($v['filename']) . "'\n\t\t\t\tAND download_tree = " . (int) $tree['tree_id']; if (!($download = $this->_fieldrow($sql))) { _fatal(); } if ($download['download_login']) { _login(); } $filepath = LIB . 'get/' . _filename($download['download_id'], $download['download_extension']); return; }
protected function _create_home() { global $core, $user; if (_button() && is_ghost()) { $v = $this->__(array('cat' => 1, 'ticket_group' => 0, 'ticket_title', 'ticket_text', 'ticket_username', 'attachments')); $t_contact = $user->v(); if (f($v['ticket_username']) && _auth_get('ticket_create_admin')) { if (!preg_match('#^([a-z0-9\\_\\-]+)$#is', $v['ticket_username'])) { $this->_error('#SIGN_LOGIN_ERROR'); } $sql = 'SELECT * FROM _members WHERE user_username = ? AND user_id <> 1 AND user_active = 1'; if (!($t_contact = _fieldrow(sql_filter($sql, $v['ticket_username'])))) { $this->_error('#SIGN_LOGIN_ERROR'); } } if (!($ticket_status = $core->cache_load('ticket_status_default'))) { $sql = 'SELECT status_id FROM _tickets_status WHERE status_default = 1'; $ticket_status = $core->cache_store(_field($sql, 'status_id', 0)); } $v2 = array('code' => substr(md5(unique_id()), 0, 8), 'childs' => 0, 'parent' => 0, 'deleted' => 0, 'lastreply' => (int) $user->time, 'group' => $v['ticket_group'], 'contact' => $t_contact['user_id'], 'aby' => 0, 'cat' => $v['cat'], 'status' => $ticket_status, 'start' => (int) $user->time, 'end' => 0, 'ip' => $user->i_ip, 'title' => $v['ticket_title'], 'text' => $v['ticket_text']); $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $v2)); $v['ticket_id'] = _sql_nextid($sql); $v = array_merge($v, $v2); if (f($v['attachments'])) { $attachments = explode(',', $v['attachments']); $location = XFS . 'space/f/'; if (@is_dir($location)) { @(include XFS . 'core/upload.php'); $upload = new upload(); $umask = umask(0); $i = 0; foreach ($attachments as $row) { if (@file_exists($location . $row)) { $extension = _extension($row); if (preg_match('/\\.(' . $upload->ext_blacklist . ')$/', strtolower($row))) { $extension = 'txt'; } $filepath = _filename('_' . $v['code'] . '_' . $i, $extension); @rename($location . $row, $location . $filepath); $upload->chmod($location . $filepath); $insert_attach = array('ticket' => $v['ticket_id'], 'name' => $filepath, 'mime' => mime_content_type($location . $filepath), 'extension' => $extension, 'size' => filesize($location . $filepath), 'checksum' => md5_file($location . $filepath), 'downloads' => 0, 'time' => time()); $sql = 'INSERT INTO _tickets_attach' . _build_array('INSERT', prefix('attach', $insert_attach)); _sql($sql); $i++; } } @umask($umask); } } if ($v['parent']) { $sql = 'UPDATE _tickets SET ticket_childs = ticket_childs + 1 WHERE ticket_id = ?'; _sql(sql_filter($sql, $v['ticket_parent'])); } if (f($v['ticket_username'])) { $insert_note = array('ticket_id' => (int) $v['ticket_id'], 'user_id' => $user->v('user_id'), 'note_text' => _lang('TICKET_CREATE_STAFF'), 'note_time' => time(), 'note_cc' => 1); $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $insert_note); _sql($sql); } $sql = 'SELECT group_name, group_email FROM _groups WHERE group_id = ?'; $d_group = _fieldrow(sql_filter($sql, $v['ticket_group'])); $ticket_subject = entity_decode($d_group['group_name'] . ' [#' . $v['code'] . ']: ' . $v['ticket_title']); $ticket_message = entity_decode($v['text']); $sql = 'SELECT m.user_email FROM _groups_members gm, _members m WHERE gm.member_group = ? AND gm.member_mod = ? AND gm.member_uid = m.user_id ORDER BY m.user_email'; $group_members = _rowset(sql_filter($sql, $v['group'], 1), false, 'user_email'); // // Common email notification require_once XFS . 'core/emailer.php'; $emailer = new emailer(); $emailer_vars = array('USERNAME' => $t_contact['user_username'], 'FULLNAME' => entity_decode(_fullname($t_contact)), 'SUBJECT' => entity_decode($v['ticket_title']), 'MESSAGE' => $ticket_message, 'TICKET_URL' => _link($this->m(), array('x1' => 'view', 'code' => $v['code']))); $email_from = $d_group['group_email'] . '@' . $core->v('domain'); $user_template = 'ticket_' . $d_group['group_email']; // // Notify ticket creator $emailer->from($email_from); $emailer->set_subject($ticket_subject); $emailer->use_template($user_template); $emailer->email_address($t_contact['user_email']); $emailer->set_decode(true); $emailer->assign_vars($emailer_vars); $emailer->send(); $emailer->reset(); // // Notify group mods $emailer->from($email_from); $emailer->use_template('ticket_tech'); $emailer->set_subject($ticket_subject); foreach ($group_members as $i => $row) { $method = !$i ? 'email_address' : 'cc'; $emailer->{$method}($row); } $emailer->set_decode(true); $emailer->assign_vars($emailer_vars); $emailer->send(); $emailer->reset(); return $this->e(_link($this->m(), array('x1' => 'view', 'code' => $v['code']))); } $sql = 'SELECT group_id, group_name FROM _groups ORDER BY group_name'; _rowset_style($sql, 'groups'); $sql = 'SELECT cat_id, cat_name FROM _tickets_cat WHERE cat_id > 0 AND cat_group IN (??) GROUP BY cat_name ORDER BY cat_group, cat_name'; if (!($cat = _rowset_style(sql_filter($sql, $user->auth_groups()), 'cat', 'cat'))) { _style('no_cat'); } return v_style(array('CHANGE_USER' => sprintf(_lang('TICKET_CHANGE_USER'), _fullname($user->v())))); }
private function childs($use_child = true) { global $user; $svar = $use_child ? 'child' : 'child2'; if (!($s_child = count($this->{$svar}))) { return; } $d_images = w(); if ($this->data['tree_schilds']) { $sql = 'SELECT tree_id, image_id, image_extension FROM _images WHERE tree_id IN (??) ORDER BY RAND()'; $images = _rowset(sql_filter($sql, _implode(',', array_keys($this->{$svar})))); foreach ($images as $rows) { if (!isset($d_images[$row['tree_id']])) { $d_images[$row['tree_id']] = _filename($row['image_id'], $row['image_extension']); } } } _style($svar, array('ORDER_URL' => _link($this->data['tree_id'], array('order', 0, 0, 0, 0)))); // TODO: Replace _linkf funcion to _link_alias foreach ($this->{$svar} as $a => $row) { _style($svar . '.item', array('ID' => $row['tree_id'], 'U' => _linkf($a, $row['tree_furl']), 'L' => $user->ls('tree', 'title', $row), 'I' => isset($d_images[$a]) ? $d_images[$a] : 'def.gif', 'DU' => $this->u_dynamic($row))); } if ($use_child) { $this->childs(false); } return; }
function home() { global $user, $style; $v = $this->__(array('f', 'e')); if (empty($v['f']) || empty($v['e'])) { _fatal(); } $filepath = './style/' . $v['e'] . '/'; $filename = _filename($v['f'], $v['e']); $browser = array('firefox' => 'Gecko', 'ie' => 'IE', 'comp' => 'compatible'); $sv = w(); switch ($v['e']) { case 'css': $sv['CSSPATH'] = LIBD . 'style'; foreach ($browser as $css_k => $css_v) { $css_match = (strstr($user->browser, $css_v) || $css_v === true) ? true : false; if ($css_match && @file_exists($filepath . '_tree_' . $css_k . '.css')) { $style->set_filenames(array('css' => 'css/_tree_' . $css_k . '.css')); $style->assign_var_from_handle('S_CSS', 'css'); $style->assign_block_vars('includes', array('CSS' => $style->vars['S_CSS'])); } $sv[strtoupper($css_k)] = $css_match; } $this->as_vars($sv); break; case 'js': if (!@file_exists($filepath . $filename)) { _fatal(); } require_once(XFS . 'core/jsmin.php'); foreach ($browser as $css_k => $css_v) { $css_match = (strstr($user->browser, $css_v) || $css_v === true) ? true : false; $sv[strtoupper($css_k)] = $css_match; } break; } if ($sv['COMP'] || $sv['FIREFOX']) { ob_start('ob_gzhandler'); } // Headers header('Content-type: text/css; charset=utf-8'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (60 * 60 * 24 * 30)) . ' GMT'); // TODO: 304 Not modified response header /*$lastmodified = filemtime($filename); if ($lastmodified) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastmodified) { header("HTTP/1.0 304 Not Modified"); } //exit; } else { header('Last-Modified: ' . gmdate('D, d, M Y H:i:s', $lastmodified) . ' GMT'); }*/ if ($v['e'] == 'js') { $style->replace_vars = false; } sql_close(); $style->set_filenames(array('body' => $v['e'] . '/' . $filename)); $style->assign_var_from_handle('EXT', 'body'); switch ($v['e']) { case 'css': $code = str_replace(array("\r\n", "\n", "\t"), '', $style->vars['EXT']); break; case 'js': $code = JSMin::minify($style->vars['EXT']); break; } echo $code; exit; }
public function home() { global $user; $v = $this->__(w('f e')); if (array_empty($v)) { _fatal(); } $location = './style/' . $v['e'] . '/'; $filename = _filename($v['f'], $v['e']); if (!@is_dir($location)) { _fatal(); } if ($v['e'] == 'css' && $v['f'] != 'default') { $v['field'] = !is_numb($v['f']) ? 'alias' : 'id'; $sql = 'SELECT * FROM _tree WHERE tree_?? = ? LIMIT 1'; if (!($tree = _fieldrow(sql_filter($sql, $v['field'], $v['f'])))) { _fatal(); } $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v['e']); } // 304 Not modified response header if (@file_exists($location . $filename)) { $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT'; $http_if_none_match = v_server('HTTP_IF_NONE_MATCH'); $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE'); header('Last-Modified: ' . $f_last_modified); if ($f_last_modified == $http_if_modified_since) { header('HTTP/1.0 304 Not Modified'); header('Content-Length: 0'); exit; } } switch ($v['e']) { case 'css': if ($v['f'] != 'default') { $filetree = _rewrite($tree); $filename = _filename('_tree_' . $filetree, $v['e']); if (!@file_exists($location . $filename)) { _fatal(); } } $browser = _browser(); if (f($browser['browser'])) { $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']); foreach ($custom as $row) { $handler = _filename('_tree_' . $row, 'css'); if (@file_exists($location . $handler)) { _style('includes', array('CSS' => _style_handler('css/' . $handler))); } } } break; case 'js': if (!@file_exists($location . $filename)) { _fatal(); } _style_vreplace(false); break; } v_style(array('SPATH' => LIBD . 'visual')); sql_close(); $ext = _style_handler($v['e'] . '/' . $filename); switch ($v['e']) { case 'css': $content_type = 'text/css; charset=utf-8'; $ext = preg_replace('#(border-radius\\-?.*?)\\: ?(([0-9]+)px;)#is', _browser('firefox') || _browser('namoroka') ? '-moz-\\1: \\2' : '', $ext); $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext); $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext); $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext); break; case 'js': $content_type = 'application/x-javascript'; require_once XFS . 'core/jsmin.php'; $ext = JSMin::minify($ext); break; } ob_start('ob_gzhandler'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 30) . ' GMT'); header('Content-type: ' . $content_type); echo $ext; exit; }
protected function _fetch_home() { global $bio, $warning; $v = $this->__(w('alias filename ext')); if (empty($v->alias) || empty($v->filename)) { $warning->now(); } $sql = 'SELECT * FROM _fetch WHERE fetch_alias = ?'; if (!($fetch = sql_fieldrow(sql_filter($sql, $v->filename)))) { $warning->now(); } if ($fetch->fetch_login) { $bio->login(); } $filepath = LIB . 'fetch/' . _filename($fetch->fetch_id, $fetch->fetch_extension); return; }
public function resize(&$row, $folder_a, $folder_b, $filename, $measure, $mscale = true, $watermark = true, $remove = false, $exif_source = false) { $a_filename = _filename($filename, $row['extension']); $source = $folder_a . $row['filename']; $destination = $folder_b . $a_filename; // Get image data from source list($width, $height, $type, $void) = @getimagesize($source); if ($width < 1 && $height < 1) { return false; } if ($width < $measure[0] && $height < $measure[1]) { $measure[0] = $width; $measure[1] = $height; } $scale_mode = $mscale === true ? 'c' : 'v'; $row = array_merge($row, array('width' => $width, 'height' => $height, 'mwidth' => $measure[0], 'mheight' => $measure[1])); $row = array_merge($row, $this->scale($scale_mode, $row)); switch ($type) { case IMG_JPG: $image_f = 'imagecreatefromjpeg'; $image_g = 'imagejpeg'; $image_t = 'jpg'; break; case IMG_GIF: $image_f = 'imagecreatefromgif'; $image_g = 'imagegif'; $image_t = 'gif'; break; case IMG_PNG: $image_f = 'imagecreatefrompng'; $image_g = 'imagepng'; $image_t = 'png'; break; } if (!($image = @$image_f($source))) { return false; } @imagealphablending($image, true); $thumb = @imagecreatetruecolor($row['width'], $row['height']); @imagecopyresampled($thumb, $image, 0, 0, 0, 0, $row['width'], $row['height'], $width, $height); // Watermark if ($watermark) { $wm = imagecreatefrompng($this->watermark_path); $wm_w = imagesx($wm); $wm_h = imagesy($wm); // Bottom right $dest_x = $row['width'] - $wm_w - 5; $dest_y = $row['height'] - $wm_h - 5; // imagecopymerge($thumb, $wm, $dest_x, $dest_y, 0, 0, $wm_w, $wm_h, 100); // imagedestroy($wm); // Centered // $dest_x = round(($row['width'] / 2) - ($wm_w / 2)); // $dest_y = round(($row['height'] / 2) - ($wm_h / 2)); $thumb = $this->alpha_overlay($thumb, $wm, $wm_w, $wm_h, $dest_x, $dest_y, 100); } $hook_arr = array($thumb, $destination); if ($type == IMG_JPG) { $hook_arr[] = 85; } if (!hook($image_g, $hook_arr) || !@file_exists($destination)) { return false; } if ($exif_source !== false && @file_exists($exif_source) && ($d_exif = @exif_read_data($exif_source))) { $this->_rotate($d_exif, $destination, $destination); } $this->chmod($destination); @imagedestroy($thumb); @imagedestroy($image); if ($remove && @file_exists($source)) { $this->remove($source); } $row['filename'] = $a_filename; return $row; }