public function render($block)
 {
     if (!function_exists('_lang')) {
         throw new Exception('You need to define _lang() function in order to use ${lang:...} template construct');
     }
     return _lang($this->path);
 }
Exemple #2
0
    protected function _create_home()
    {
        global $user;
        $v = $tree = $this->init();
        $z = $this->__(w('zmode'));
        if (_button()) {
            $v_ary = array('subject', 'content');
            if ($user->v('is_founder')) {
                $v_ary = array_merge($v_ary, array('node' => 0, 'parent' => 0, 'level' => 0, 'module' => 0, 'alias', 'child_hide' => 0, 'child_order', 'nav' => 0, 'nav_hide' => 0, 'css_parent' => 0, 'css_var', 'quickload' => 0, 'dynamic' => 0, 'tags', 'template', 'redirect', 'description', 'allow_comments' => 0, 'approve_comments' => 0, 'form' => 0, 'form_email', 'published', 'move'));
            }
            $v = $this->__($v_ary);
            /*
            $v = $this->__(array(
            	'node' => 0,
            	'parent' => 0,
            	'level' => 0,
            	'module' => 0,
            	'alias',
            	'child_hide' => 0,
            	'child_order',
            	'nav' => 0,
            	'nav_hide' => 0,
            	'css_parent' => 0,
            	'css_var',
            	'quickload' => 0,
            	'dynamic' => 0,
            	'tags',
            	'template',
            	'redirect',
            	'subject',
            	'content',
            	'description',
            	'allow_comments' => 0,
            	'approve_comments' => 0,
            	'form' => 0,
            	'form_email',
            	'published',
            	'move'
            ));
            */
            //
            $v['edited'] = time();
            foreach (w('node level parent module') as $row) {
                $v[$row] = $tree['tree_' . $row];
            }
            if ($z['zmode'] == 'create') {
                $v['parent'] = $tree['tree_id'];
                $v['level']++;
                if (!$v['node']) {
                    $v['node'] = $v['parent'];
                }
            }
            // Parse vars
            foreach ($v as $row_k => $row_v) {
                switch ($row_k) {
                    case 'subject':
                        $row_v = $this->html($row_v, 'strong');
                        break;
                    case 'content':
                        $row_v = $this->html($row_v);
                        break;
                    case 'alias':
                        $row_v = _alias($row_v, w('_'), '-');
                        break;
                    case 'checksum':
                        $row_v = _hash($v['content']);
                        break;
                    case 'published':
                        $row_v = dvar($row_v, date('d m Y'));
                        $e_date = explode(' ', $row_v);
                        $row_v = _timestamp($e_date[1], $e_date[0], $e_date[2]);
                        break;
                }
                $v[$row_k] = $row_v;
            }
            if ($z['zmode'] == 'modify' && $tree['tree_alias'] == 'home' && $v['alias'] != 'home') {
                $v['alias'] = 'home';
            }
            if (f($v['alias'])) {
                $sql = 'SELECT tree_id
					FROM _tree
					WHERE tree_alias = ?
						AND tree_id <> ?';
                if (_fieldrow(sql_filter($sql, $v['alias'], $tree['tree_id']))) {
                    $this->_error('#ALIAS_IN_USE');
                }
            }
            if ($z['zmode'] == 'modify') {
                if ($v['move']) {
                    $mv_field = !is_numb($v['move']) ? 'alias' : 'id';
                    $sql = 'SELECT *
						FROM _tree
						WHERE tree_?? = ?';
                    if ($mv_tree = _fieldrow(sql_filter($sql, $mv_field, $v['move']))) {
                        $mv_insert = array('module' => $mv_tree['module_id'], 'node' => $mv_tree['tree_node'], 'parent' => $mv_tree['tree_id'], 'level' => $mv_tree['tree_level'] + 1);
                        $sql = 'UPDATE _tree SET ' . _build_array('UPDATE', prefix('tree', $mv_insert)) . sql_filter('
							WHERE article_id = ?', $tree['tree_id']);
                        _sql($sql);
                        $sql = 'UPDATE _tree SET tree_childs = tree_childs - 1
							WHERE tree_id = ?';
                        _sql(sql_filter($sql, $tree['tree_parent']));
                        $sql = 'UPDATE _tree SET tree_childs = tree_childs + 1
							WHERE tree_id = ?';
                        _sql(sql_filter($sql, $mv_tree['tree_id']));
                    }
                }
                unset($v['move']);
                // Check input values against database
                foreach ($v as $row_k => $row_v) {
                    if ($tree['tree_' . $row_k] == $row_v) {
                        unset($v[$row_k]);
                    }
                }
                if (!(count($v) - 1)) {
                    unset($v['edited']);
                }
            } else {
                unset($v['move']);
            }
            //
            $u_tree = _rewrite($tree);
            if (count($v)) {
                if (isset($v['content']) && $v['content']) {
                    $v['content'] = str_replace(w('&lt; &gt;'), w('< >'), $v['content']);
                }
                if ($z['zmode'] == 'create') {
                    $sql = 'INSERT INTO _tree' . _build_array('INSERT', prefix('tree', $v));
                } else {
                    $sql = 'UPDATE _tree SET ' . _build_array('UPDATE', prefix('tree', $v)) . sql_filter('
						WHERE tree_id = ?', $tree['tree_id']);
                }
                _sql($sql);
                if ($z['zmode'] == 'create') {
                    $u_tree = f($v['alias']) ? $v['alias'] : _nextid();
                    $sql = 'UPDATE _tree
						SET tree_childs = tree_childs + 1
						WHERE tree_id = ?';
                    _sql(sql_filter($sql, $tree['tree_id']));
                }
            }
            redirect(_link($u_tree));
        }
        //
        // Show fieldset
        /*$v_fieldset = array(
        			'subject',
        			'content',
        			'description',
        			'alias',
        			'child_hide' => 0,
        			'child_order',
        			'nav' => 0,
        			'nav_hide' => 0,
        			'css_parent',
        			'css_var',
        			'quickload' => 0,
        			'dynamic' => 0,
        			'tags',
        			'template',
        			'redirect',
        			'allow_comments' => 0,
        			'approve_comments' => 0,
        			'form' => 0,
        			'form_email',
        			'published'
        		);
        		*/
        $v_fieldset = array('subject', 'content');
        if ($user->v('is_founder')) {
            $v_fieldset = array_merge($v_fieldset, array('description', 'alias', 'child_hide' => 0, 'child_order', 'nav' => 0, 'nav_hide' => 0, 'css_parent', 'css_var', 'quickload' => 0, 'dynamic' => 0, 'tags', 'template', 'redirect', 'allow_comments' => 0, 'approve_comments' => 0, 'form' => 0, 'form_email', 'published'));
        }
        $is_modify = $z['zmode'] == 'modify';
        foreach (_array_keys($v_fieldset, '') as $k => $row) {
            $name = 'tree_' . $k;
            $cp_lang = _lang('CP_' . $k);
            $value = $is_modify ? isset($v[$k]) ? $v[$k] : (isset($tree[$name]) ? $tree[$name] : '') : '';
            $checked = is_numb($row) && $is_modify && $tree[$name] ? ' checked="checked"' : '';
            if (f($value)) {
                switch ($k) {
                    case 'published':
                        $value = date('d m Y', $value);
                        break;
                }
            }
            $type = 'text';
            if (is_numb($row)) {
                $value = 1;
                $type = 'checkbox';
            }
            $tag = 'input';
            if ($k == 'content') {
                $tag = 'textarea';
            }
            _style('field', array('NAME' => $k, 'ID' => $k, 'TAG' => $tag, 'TYPE' => $type, 'VALUE' => $value, 'LANG' => $cp_lang, 'CHECKED' => $checked));
            if ($k == 'template') {
                $i = 0;
                $fp = @opendir('./style/custom/');
                while ($row_d = @readdir($fp)) {
                    if (_extension($row_d) != 'htm') {
                        continue;
                    }
                    if (!$i) {
                        _style('field.templated');
                        _style('field.templated.row', array('V' => '', 'FILE' => _lang('NONE')));
                    }
                    $v_file = str_replace('.htm', '', $row_d);
                    _style('field.templated.row', array('V' => $v_file, 'FILE' => $v_file));
                    $i++;
                }
                @closedir($fp);
            }
            //
        }
        $cp_format = !$is_modify ? 'CREATE' : 'MODIFY';
        v_style(array('CP_PAGE' => sprintf(_lang('CP_PAGE_' . $cp_format), $tree['tree_subject'])));
        return;
    }
Exemple #3
0
 function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay)
 {
     $mime_boundary = "--==================_846811060==_";
     $this->msg = '--' . $mime_boundary . "\nContent-Type: text/plain;\n\tcharset=\"" . _lang('ENCODING') . "\"\n\n" . $this->msg;
     if ($mime_filename) {
         $filename = $mime_filename;
         $encoded = $this->encode_file($filename);
     }
     $fd = fopen($filename, "r");
     $contents = fread($fd, filesize($filename));
     $this->mimeOut = "--" . $mime_boundary . "\n";
     $this->mimeOut .= "Content-Type: " . $mimetype . ";\n\tname=\"{$szFilenameToDisplay}\"\n";
     $this->mimeOut .= "Content-Transfer-Encoding: quoted-printable\n";
     $this->mimeOut .= "Content-Disposition: attachment;\n\tfilename=\"{$szFilenameToDisplay}\"\n\n";
     if ($mimetype == "message/rfc822") {
         $this->mimeOut .= "From: " . $szFromAddress . "\n";
         $this->mimeOut .= "To: " . $this->emailAddress . "\n";
         $this->mimeOut .= "Date: " . date("D, d M Y H:i:s") . " UT\n";
         $this->mimeOut .= "Reply-To:" . $szFromAddress . "\n";
         $this->mimeOut .= "Subject: " . $this->mailSubject . "\n";
         $this->mimeOut .= "X-Mailer: PHP/" . phpversion() . "\n";
         $this->mimeOut .= "MIME-Version: 1.0\n";
     }
     $this->mimeOut .= $contents . "\n";
     $this->mimeOut .= "--" . $mime_boundary . "--" . "\n";
     return $this->mimeout;
     // added -- to notify email client attachment is done
 }
         $template->pparse('body');
         if (!defined('IN_PCP')) {
             include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
         }
     } else {
         // display the page
         $page_title = _lang('Search_pm');
         if (!defined('IN_PCP')) {
             include $phpbb_root_path . 'includes/page_header.' . $phpEx;
         }
         $template->set_filenames(array('body' => 'privmsga_search_body.tpl'));
         privmsg_header($view_user_id, $folder_id, $privmsg_recip_id);
         // header
         $template->assign_vars(array('L_TITLE' => _lang('Search_pm'), 'L_SEARCH_FOLDER' => _lang('Search_folder'), 'L_SEARCH_FOLDER_EXPLAIN' => _lang('Search_folder_explain'), 'L_SEARCH_AUTHOR' => _lang('Search_recipient'), 'L_SEARCH_AUTHOR_EXPLAIN' => _lang('Search_recipient_explain'), 'L_SEARCH_WORDS' => _lang('Search_words'), 'L_SEARCH_WORDS_EXPLAIN' => _lang('Search_words_explain'), 'L_SUBMIT' => _lang('Submit'), 'L_CANCEL' => _lang('Cancel'), 'L_FIND_USERNAME' => _lang('Find_username'), 'U_SEARCH_USER' => append_sid("search.{$phpEx}?mode=searchuser")));
         // data
         $s_folders = '<option value="-1">' . _lang('All_folders') . '</option>' . get_folders_list(0, $folder_id);
         // vars
         $template->assign_vars(array('S_FOLDERS' => $s_folders, 'USERNAME' => empty($username) ? '' : str_replace("''", "'", $username), 'WORDS' => empty($search_words) ? '' : str_replace("''", "'", implode(', ', $search_words))));
         // system
         _hide(POST_USERS_URL, $view_user_id);
         _hide('pmmode', $pmmode);
         _hide('sid', $userdata['session_id']);
         $template->assign_vars(array('S_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FIELDS' => _hidden_get()));
         // send to browser
         privmsg_footer();
         $template->pparse('body');
         if (!defined('IN_PCP')) {
             include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
         }
     }
 }
Exemple #5
0
    public function home()
    {
        global $core, $user;
        $tree = $this->valid_tree();
        $v = $this->__(_array_keys(w('is_comment is_form'), 0));
        // Form posting enabled and form submitted
        if ($v['is_form'] && _button()) {
            if (!is_ghost()) {
                _fatal(405);
            }
            if (!$tree['tree_form']) {
                _fatal();
            }
            $sql_fields = 'SELECT form_alias, form_required, form_legend, form_regex, 
				FROM _form_fields
				WHERE form_tree = ?
				ORDER BY form_order';
            if (!($form = _rowset(sql_filter($sql_fields, $tree['tree_id']), 'form_alias'))) {
                $form = _rowset(sql_filter($sql_fields, 0), 'form_alias');
            }
            $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => _lang('XCF_LEGEND'));
            foreach ($form as $row) {
                $v = array_merge($v, $this->__(array($row['form_alias'])));
                if (!f($v[$row['form_alias']])) {
                    if ($row['form_required']) {
                        $this->_error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false);
                    }
                    continue;
                }
                if (f($row['form_regex']) && !preg_match('#' . $row['form_regex'] . '#is', $v[$row['form_alias']])) {
                    $this->_error(sprintf(_lang('E_COMMENT_FIELD_BAD'), $row['form_legend']), false);
                    if ($row['form_alias'] == 'secure') {
                        $v[$row['form_alias']] = '';
                    }
                }
            }
            require_once XFS . 'core/xcf.php';
            $xcf = new captcha();
            if ($xcf->check($v['secure']) === false) {
                $v['secure'] = '';
                $this->_error('#E_COMMENT_INVALID_CAPTCHA');
            }
            unset($xcf);
            require_once XFS . 'core/emailer.php';
            $emailer = new emailer();
            $emailer->set_decode(true);
            $emailer->format('plain');
            $emailer->from($v['address']);
            $emailer->set_subject(_rm_acute($v['subject']));
            $emailer->use_template('contact_email');
            if (f($core->v('default_email'))) {
                $tree['tree_form_email'] .= (f($tree['tree_form_email']) ? ';' : '') . $core->v('default_email');
            }
            $form_addresses = array_map('trim', array_unique(explode(';', $tree['tree_form_email'])));
            foreach ($form_addresses as $i => $address) {
                $row_f = !$i ? 'email_address' : 'cc';
                $emailer->{$row_f}($address);
            }
            unset($v['secure']);
            $content = w();
            foreach ($form as $row) {
                if (!f($v[$row['form_alias']])) {
                    continue;
                }
                $content[] = $row['form_legend'] . ":\n" . $v[$row['form_alias']];
            }
            $emailer->assign_vars(array('CONTENT' => implode("\n\n", $content), 'FORM_ARTICLE' => $tree['tree_subject']));
            $emailer->send();
            $emailer->reset();
            $response = array('lang' => _lang('FORM_SUCCESS'));
            $this->e(json_encode($response));
        }
        // Comment posting enabled and form submitted.
        if ($v['is_comment'] && _button()) {
            if (!$tree['tree_allow_comments']) {
                _fatal();
            }
            $cv = $this->__(w('comment_username comment_address comment_website comment_message comment_security'));
            $comment_time = time();
            if (!$user->v('is_member')) {
                foreach ($cv as $cv_k => $cv_v) {
                    if (!f($cv_v)) {
                        $this->error('E_COMMENT_FILL_FIELDS');
                        break;
                    }
                }
                if (!$this->errors()) {
                    $sql = 'SELECT comment_time
						FROM _comments
						WHERE comment_ip = ?
							AND comment_status = 0';
                    if ($row_flood = _fieldrow(sql_filter($sql, $user->ip))) {
                        if ($comment_time - $row_flood['comment_time'] < 30) {
                            $this->error('E_COMMENT_FLOOD_TIME');
                        }
                    }
                }
                // CAPTCHA verification
                require_once XFS . 'core/xcf.php';
                $xcf = new captcha();
                if ($xcf->check($cv['comment_security']) === false) {
                    $cv['comment_security'] = '';
                    $this->error('E_COMMENT_INVALID_CAPTCHA');
                }
                unset($xcf);
            }
            if (!$this->errors()) {
                $approve_comments = !$user->v('is_member') ? $tree['tree_approve_comments'] : 1;
                $sql_insert = array('tree' => (int) $tree['tree_id'], 'uid' => (int) $user->v('user_id'), 'username' => $cv['comment_username'], 'email' => $cv['comment_address'], 'website' => $cv['comment_website'], 'ip' => $user->ip, 'status' => (int) $approve_comments, 'time' => (int) $comment_time, 'message' => $cv['comment_message']);
                $sql = 'INSERT INTO _comments' . _build_array('INSERT', prefix('comment', $sql_insert));
                _sql($sql);
                if ($approve_comments) {
                    $sql = 'UPDATE _tree SET tree_comments = tree_comments + 1
						WHERE tree_id = ?';
                    _sql(sql_filter($sql, $tree['tree_id']));
                }
                // Send new comment email notification for approval.
                if (!$approve_comments) {
                    unset($cv['comment_security']);
                    require_once XFS . 'core/emailer.php';
                    $emailer = new emailer();
                    $emailer->from($cv['comment_address']);
                    $emailer->use_template('comment_approval');
                    if (f($tree['tree_form_email'])) {
                        $tree['tree_form_email'] = $core->v('default_comments_email');
                    }
                    foreach (explode(';', $tree['tree_form_email']) as $i => $row) {
                        $row_f = !$i ? 'email_address' : 'cc';
                        $emailer->{$row_f}($row);
                    }
                    $input = w();
                    foreach ($cv as $row_k => $row_v) {
                        if (!f($row_v)) {
                            continue;
                        }
                        if ($row_k == 'comment_message') {
                            $row_v = str_replace("\r\n", '<br />', $row_v);
                        }
                        $input[] = '&lt; ' . $row_v;
                    }
                    $emailer->assign_vars(array('U_APPROVAL' => _link(_rewrite($tree), array('x1' => 'comments')), 'INPUT_FIELDS' => implode('<br /><br />', $input), 'FROM_USERNAME' => $cv['comment_username']));
                    $emailer->send();
                    $emailer->reset();
                }
                redirect(_link(_rewrite($tree)));
            }
            if ($this->errors()) {
                if (is_ghost()) {
                    $this->e('!');
                }
                _style('comments_error', array('MESSAGE' => $this->get_errors()));
            }
        }
        //
        if (f($tree['tree_redirect'])) {
            if (preg_match('#^[a-z0-9\\-\\_]+$#is', $tree['tree_redirect'])) {
                $tree['tree_redirect'] = _link($tree['tree_redirect']);
            }
            redirect($tree['tree_redirect']);
        }
        //
        if ($tree['tree_parent']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ?';
            $parent = _fieldrow(sql_filter($sql, $tree['tree_parent']));
            if ($tree['tree_level'] > 2) {
                $sql = 'SELECT *
					FROM _tree
					WHERE tree_id = ?';
                $subparent = _fieldrow(sql_filter($sql, $parent['tree_parent']));
            }
        }
        if ($tree['tree_node']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ?';
            $node = _fieldrow(sql_filter($sql, $tree['tree_node']));
        }
        //
        if (@method_exists($this, 'cf_' . _rewrite($tree))) {
            $this->{'cf_' . _rewrite($tree)}($tree);
        }
        //
        $sql = 'SELECT *
			FROM _tree
			WHERE tree_parent = ?
				AND tree_child_hide = 0
			ORDER BY ??';
        $childs = _rowset(sql_filter($sql, $tree['tree_id'], $this->child_order($tree)));
        foreach ($childs as $i => $row) {
            if (!$i) {
                $sql = 'SELECT image_id, image_tree, image_extension
					FROM _images
					WHERE image_tree IN (??)
					ORDER BY RAND()';
                $images_child = _rowset(sql_filter($sql, _implode(',', array_keys($childs))), 'tree_id');
                _style('tree_child1', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0))));
            }
            _style('tree_child.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'SUBJECT' => $row['tree_subject'], 'CONTENT' => $row['tree_content'], 'EDITED' => _format_date($row['tree_edited']), 'IMAGE' => isset($images_child[$row['tree_id']]) ? $images_child[$row['tree_id']]['image_id'] . '.' . $images_child[$row['tree_id']]['image_extension'] : 'default.gif'));
        }
        // Comments
        if ($tree['tree_allow_comments'] && $tree['tree_comments']) {
            $sql = 'SELECT c.comment_id, c.comment_username, c.comment_website, c.comment_time, c.comment_message, m.user_username
				FROM _comments c, _members m
				WHERE c.comment_tree = ?
					AND c.comment_status = 1
					AND c.comment_uid = m.user_id
				ORDER BY c.comment_time DESC';
            $comments = _rowset(sql_filter($sql, $tree['tree_id']));
            foreach ($comments as $i => $row) {
                if (!$i) {
                    _style('comments');
                }
                _style('comments.row', array('ID' => $row['comment_id'], 'SUSERNAME' => $row['user_username'], 'USERNAME' => $row['comment_username'], 'WEBSITE' => $row['comment_website'], 'TIME' => _format_date($row['comment_time']), 'MESSAGE' => str_replace("\n", '<br />', $row['comment_message'])));
            }
        }
        //
        if ($this->css_parent($tree)) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_parent = ?
					AND tree_child_hide = 0
				ORDER BY ??';
            $childs_parent = _rowset(sql_filter($sql, $this->css_var($tree), $this->child_order($tree)));
            foreach ($childs_parent as $i => $row) {
                if (!$i) {
                    $sql = 'SELECT image_id, image_tree, image_extension
						FROM _images
						WHERE image_tree IN (??)
						ORDER BY RAND()';
                    $images_child_parent = _rowset(sql_filter($sql, _implode(',', array_keys($childs_parent))), 'tree_id');
                    _style('tree_child', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0))));
                }
                _style('tree_child_parent.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'TITLE' => $row['tree_subject'], 'IMAGE' => isset($images_child_parent[$row['tree_id']]) ? $images_child_parent[$row['tree_id']]['image_id'] . '.' . $images_child_parent[$row['tree_id']]['image_extension'] : 'default.gif'));
            }
        }
        if ($tree['tree_downloads']) {
            $sql = 'SELECT *
				FROM _downloads
				WHERE download_tree = ?
				ORDER BY download_order';
            $downloads = _rowset(sql_filter($sql, $tree['tree_id']));
            foreach ($downloads as $i => $row) {
                if (!$i) {
                    _style('downloads', array('ORDER_URL' => _link($tree['tree_id'], array('orderd', 0, 0, 0, 0))));
                }
                _style('downloads.row', array('ITEM' => $row['download_id'], 'DOWNLOAD' => _link('get', $row['download_alias'] . '.' . $row['download_extension']), 'TITLE' => $row['download_title']));
            }
        }
        //
        if ($tree['tree_form']) {
            $sql = 'SELECT *
				FROM _form_fields
				WHERE form_tree = ?
				ORDER BY form_order';
            $form = _rowset(sql_filter($sql, $tree['tree_id']), 'form_alias');
            if (!count($form)) {
                $sql = 'SELECT *
					FROM _form_fields
					WHERE form_tree = 0
					ORDER BY form_order';
                $form = _rowset($sql, 'form_alias');
            }
            $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad');
            _style('form', array('URL' => _link(_rewrite($tree))));
            foreach ($form as $row) {
                _style('form.row', array('ALIAS' => $row['form_alias'], 'REQUIRED' => $row['form_required'], 'LEGEND' => _lang($row['form_legend']), 'TYPE' => $row['form_type'], 'PAGE' => $tree['tree_alias']));
                foreach ($row as $row_k => $row_v) {
                    if (preg_match('#^form_(alias|type)$#is', $row_k)) {
                        if ($row_k == 'form_alias') {
                            $row_k = 'name';
                        }
                        _style('form.row.attrib', array('ATTRIB' => str_replace('form_', '', $row_k), 'VALUE' => $row_v));
                    }
                }
            }
        }
        $s_css_page = '';
        if (@file_exists('./style/css/_tree_' . _rewrite($tree) . '.css')) {
            $s_css_page = _rewrite($tree) . '/';
        } elseif ($this->css_parent($tree)) {
            if (!f($tree['tree_css_var'])) {
                $tree['tree_css_var'] = 'parent';
            }
            $ary_css_var = false;
            switch ($tree['tree_css_var']) {
                case 'parent':
                case 'subparent':
                case 'node':
                    $ary_css_var = ${$tree['tree_css_var']};
                    break;
                default:
                    if (is_numb($tree['tree_css_var'])) {
                        $sql = 'SELECT *
							FROM _tree
							WHERE tree_id = ?';
                        if ($css_var_row = _fieldrow(sql_filter($sql, $tree['tree_css_var']))) {
                            $ary_css_var = $css_var_row;
                        }
                    }
                    break;
            }
            if ($ary_css_var !== false) {
                $s_css_page = _rewrite($ary_css_var) . '/';
            }
        }
        v_style(array('S_IMAGES' => $core->v('address') . 'container/images/a_' . ($this->css_parent($tree) ? $this->css_var($tree) : $tree['tree_id']) . '/', 'V_TREE' => $tree['tree_id'], 'V_CSS' => $s_css_page, 'V_SUBJECT' => $tree['tree_subject'], 'V_CONTENT' => _message($tree['tree_content']), 'V_COMMENTS' => $tree['tree_comments'], 'V_ALLOW_COMMENTS' => $tree['tree_allow_comments'], 'V_ALLOW_FORM' => $tree['tree_form'], 'U_COMMENTS' => _link(_rewrite($tree)), 'U_XCF' => _link(_rewrite($tree) . '-xs.jpg', false, false)));
        $tree['tree_subject'] = strip_tags($tree['tree_subject']);
        //
        if ($tree['tree_alias'] != 'home') {
            if ($node['tree_id'] != $parent['tree_id']) {
                $this->navigation($node['tree_subject'], _rewrite($node));
            }
            if ($tree['tree_level'] > 2) {
                if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) {
                    $this->navigation('...');
                }
                $this->navigation($subparent['tree_subject'], _rewrite($subparent));
            }
            if ($parent['tree_id']) {
                $this->navigation($parent['tree_subject'], _rewrite($parent));
            }
            $this->navigation($tree['tree_subject'], _rewrite($tree));
        }
        if ($user->v('is_member')) {
            $tree['tree_cp'] = 1;
            $i = 0;
            $auth_tree = array('create', 'modify', 'remove');
            foreach ($auth_tree as $row) {
                if (_auth_get('cp_' . $row)) {
                    if (!$i) {
                        _style('auth');
                    }
                    _style('auth.row', array('U_AUTH' => _link('cp', array($row, _rewrite($tree))), 'V_NAME' => _lang('CP_AUTH_' . $row)));
                    $i++;
                }
            }
        }
        //
        $this->_template('tree');
        if (f($tree['tree_template']) && @file_exists('./style/custom/' . $tree['tree_template'] . '.htm')) {
            $this->_template('custom/' . $tree['tree_template']);
        }
        // TODO: 304 header response
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $tree['tree_edited']) . ' GMT');
        return;
    }
 * You can copy this to /app/inc/tpl/site.error.php and update it according to your need.
 *
 * @package     PHPLucidFrame\App
 * @since       PHPLucidFrame v 1.0.0
 * @copyright   Copyright (c), PHPLucidFrame.
 * @author      Sithu K. <*****@*****.**>
 * @link        http://phplucidframe.com
 * @license     http://www.opensource.org/licenses/mit-license.php MIT License
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE
 */
?>
<!DOCTYPE html>
<html lang="<?php 
echo _lang();
?>
">
<head>
    <title><?php 
echo _title('Site Error');
?>
</title>
    <?php 
include _i('inc/tpl/head.php');
?>
</head>
<body>
    <?php 
_msg($error->message, isset($error->type) ? $error->type : 'error');
?>
function send_mail($type, $from_userdata, &$to_user_ids, &$recips, $subject, $message, $time = 0, $copy = true, $parsed_values = array())
{
    global $db, $board_config, $lang, $phpbb_root_path, $phpEx, $userdata;
    // fix some parameters
    $subject = trim($subject);
    $message = trim($message);
    // check we have a message and a subject
    if (empty($subject)) {
        return 'Empty_subject';
    }
    if (empty($message)) {
        return 'Empty_message';
    }
    // recipient is not an array, so make one
    if (!is_array($to_user_ids) && !empty($to_user_ids)) {
        $to_user_ids = array(intval($to_user_ids));
    }
    // check if recipients
    if (empty($to_user_ids)) {
        return 'No_to_user';
    }
    $s_to_user_ids = implode(', ', $to_user_ids);
    // censor words
    $orig_word = array();
    $replacement_word = array();
    obtain_word_list($orig_word, $replacement_word);
    // process some cleaning
    $subject = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($subject)) : unprepare_message($subject);
    $message = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($message)) : unprepare_message($message);
    // clean any bbcode_uid
    $subject = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $subject);
    $message = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $message);
    // clean HTML
    $subject = preg_replace('#(<)([\\/]?.*?)(>)#is', "&lt;\\2&gt;", $subject);
    $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
    // from_user_id can be 0 for sys message (sent by the board)
    if (empty($from_userdata)) {
        $from_userdata['user_id'] = 0;
        $from_userdata['user_level'] = ADMIN;
        $from_userdata['username'] = $board_config['sitename'];
    }
    $from_user_id = intval($from_userdata['user_id']);
    // get the recipients
    $sql_where = "user_email <> '' AND user_email IS NOT NULL";
    // this will require enhancement for the pcp ignore/friend list
    if (!$copy) {
        $sql_where .= " AND user_id <> " . intval($from_userdata['user_id']);
    }
    if ($userdata['user_level'] != ADMIN) {
        $sql_where .= " AND (user_viewemail = 1 OR user_id = " . intval($userdata['user_id']) . ")";
    }
    //
    // Make sure user wánts the mail
    //
    $notify_sql = '';
    $sql_notify = '';
    if ($type == 'privmsg_notify') {
        $sql_notify = ', user_notify_pm';
        $notify_sql = 'AND user_notify_pm != 0';
    }
    // read the mail recipients
    $sql = "SELECT user_id, user_email, user_lang, username" . $sql_notify . "\n                FROM " . USERS_TABLE . "\n                WHERE user_id IN ({$s_to_user_ids})\n                {$notify_sql}\n                AND user_id NOT IN (0, " . ANONYMOUS . ")\n                AND {$sql_where}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not read recipient mail list', '', __LINE__, __FILE__, $sql);
    }
    $count = 0;
    $bcc_list_ary = array();
    while ($row = $db->sql_fetchrow($result)) {
        $count++;
        $bcc_list_ary[$row['user_lang']][] = array('user_id' => $row['user_id'], 'mail' => $row['user_email'], 'username' => $row['username']);
    }
    if ($count > 0) {
        // read the message recipients
        $msg_to = '';
        if (!empty($recips)) {
            for ($i = 0; $i < count($recips); $i++) {
                $username = isset($recips[$i]['privmsg_to_username']) ? $recips[$i]['privmsg_to_username'] : $recips[$i]['username'];
                if (!empty($username)) {
                    $msg_to .= (empty($msg_to) ? '' : ', ') . $username;
                }
            }
        }
        //
        // Let's do some checking to make sure that mass mail functions
        // are working in win32 versions of php.
        //
        if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) {
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            // We are running on windows, force delivery to use our smtp functions
            // since php's are broken by default
            $board_config['smtp_delivery'] = 1;
            $board_config['smtp_host'] = @$ini_val('SMTP');
        }
        // init the mailer
        $emailer = new emailer($board_config['smtp_delivery']);
        // init server vars
        $server_name = trim($board_config['server_name']);
        $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://';
        $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/';
        // sender script
        $script_path = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path']));
        $script_path = !empty($script_name) ? $server_protocol . $server_name . $server_port . $script_name . '/' : $server_protocol . $server_name . $server_port;
        // start the emailer data
        $emailer->from($board_config['board_email']);
        $emailer->replyto($board_config['board_email']);
        // choose template
        switch ($type) {
            case 'privmsg_notify':
                $tpl = 'privmsg_notify';
                $mail_subject = _lang('Notification_subject');
                break;
            case 'save_to_mail':
                $tpl = 'admin_send_email';
                $mail_subject = _lang('Save_to_mail_subject') . $subject;
                break;
            default:
                $tpl = 'admin_send_email';
                $mail_subject = $subject;
                break;
        }
        // send message (coming partially from privmsgs.php) : one per lang
        @reset($bcc_list_ary);
        while (list($user_lang, $bcc_list) = each($bcc_list_ary)) {
            if ($count == 1) {
                $emailer->email_address($bcc_list[0]['mail']);
            } else {
                // affect users mail
                for ($i = 0; $i < count($bcc_list); $i++) {
                    $emailer->bcc($bcc_list[$i]['mail']);
                }
            }
            // remove {USERNAME} from the template if more than one recipient
            if ($count > 0) {
                $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
            }
            // build message
            $msg = _lang('Subject') . ': ' . $subject;
            $msg .= "\n" . _lang('From') . ': ' . $from_userdata['username'];
            if (!empty($msg_to)) {
                $msg .= "\n" . _lang('To') . ': ' . $msg_to;
            }
            if (!empty($time)) {
                $dformat = $board_config['default_dateformat'];
                $dtz = $board_config['board_timezone'];
                if (count($to_user_ids) == 1) {
                    $dformat = $userdata['user_dateformat'];
                    $dtz = $userdata['user_timezone'];
                }
                $post_date = create_date($dformat, $time, $dtz);
                $msg .= "\n" . _lang('Date') . ': ' . $post_date;
            }
            $msg .= "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" . $message;
            // generic values
            $parsed_values['SITENAME'] = $board_config['sitename'];
            $parsed_values['EMAIL_SIG'] = !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '';
            $parsed_values['MESSAGE'] = $msg;
            $parsed_values['FROM'] = $userdata['username'];
            $emailer->use_template($tpl, $user_lang);
            $emailer->set_subject($mail_subject);
            $emailer->assign_vars($parsed_values);
            // send
            $emailer->send();
            $emailer->reset();
        }
    }
}
    $template->set_filenames(array('body' => 'privmsga_body.tpl'));
    // send header
    privmsg_header($view_user_id, $folder_id);
    // send list
    privmsg_list($privmsg_rowset, $recips, $folder_id, true, $mark_ids);
    // pagination
    $page_list = generate_pagination("profile.{$phpEx}?mode=privmsg", $count_in_sub_folder, $board_config['topics_per_page'], $pm_start);
    $page_number = sprintf(_lang('Page_of'), floor($start / $board_config['topics_per_page']) + 1, ceil($count_in_sub_folder / $board_config['topics_per_page']));
    //$page_list      = str_replace('&amp;start', '&start', $page_list);
    $page_list = preg_replace("/\\&start\\=(\\d*)/", "javascript:document.post.start.value='\\1'; document.post.submit();", $page_list);
    // add marked on other pages
    for ($i = 0; $i < count($mark_ids); $i++) {
        if (empty($marked_on_this_page) || !in_array($mark_ids[$i], $marked_on_this_page)) {
            _hide('mark_ids[]', $mark_ids[$i]);
        }
    }
    _hide('start', $pm_start);
    _hide('pmmode', $pmmode);
    _hide('folder', $folder_id);
    _hide(POST_USERS_URL, $view_user_id);
    // mark as not first entrance
    _hide('refresh', true);
    // system
    $template->assign_vars(array('S_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FIELDS' => _hidden_get(), 'L_GOTO_PAGE' => $count_in_sub_folder < $board_config['topics_per_page'] ? '' : _lang('Goto_page'), 'PAGINATION' => $count_in_sub_folder < $board_config['topics_per_page'] ? '' : $page_list, 'PAGE_NUMBER' => $page_number));
}
// send to browser
privmsg_footer();
$template->pparse('body');
if (!defined('IN_PCP')) {
    include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
}
            default:
                $icones_sort[] = $i;
                break;
        }
    }
    // check if the icon exists
    $found = false;
    for ($i = 0; $i < count($icones_sort) && !$found; $i++) {
        $found = $icones[$icones_sort[$i]]['ind'] == $post_icon;
    }
    if (!$found) {
        $post_icon = 0;
    }
    // send to template
    $template->assign_block_vars('switch_icon_checkbox', array());
    $template->assign_vars(array('L_ICON_TITLE' => _lang('post_icon_title')));
    // display the icons
    $nb_row = intval((count($icones_sort) - 1) / $icon_per_row) + 1;
    $offset = 0;
    for ($i = 0; $i < $nb_row; $i++) {
        $template->assign_block_vars('switch_icon_checkbox.row', array());
        for ($j = 0; $j < $icon_per_row && $offset < count($icones_sort); $j++) {
            $icon_id = $icones_sort[$offset];
            // send to cell or cell_none
            $template->assign_block_vars('switch_icon_checkbox.row.cell', array('ICON_ID' => $icones[$icon_id]['ind'], 'ICON_CHECKED' => $post_icon == $icones[$icon_id]['ind'] ? ' checked="checked"' : '', 'ICON_IMG' => get_icon_title($icones[$icon_id]['ind'], 2)));
            $offset++;
        }
    }
}
// system
_hide(POST_USERS_URL, $view_user_id);
Exemple #10
0
    protected function advanced_search_form($category)
    {
        global $user;
        $sql = "SELECT *\n\t\t\tFROM _search_tables t, _search_categories c\n\t\t\tWHERE t.table_cat = c.category_id\n\t\t\t\tAND c.category_alias = ?\n\t\t\tORDER BY table_id";
        $tables = _rowset(sql_filter($sql, $category));
        foreach ($tables as $i => $row) {
            _style('search_tables', array('V_VALUE' => $row['table_id'], 'V_NAME' => _lang('TABLES_' . $row['table_alias'])));
            if (!$i) {
                $sql = 'SELECT *
					FROM _search_relation
					WHERE relation_table = ?';
                $relation = _rowset(sql_filter($sql, $row['table_id']));
                foreach ($relation as $row2) {
                    if ($row2['relation_name'] == 'Grupo') {
                        $groups = explode(',', $user->auth_groups());
                        if (count($groups) < 2) {
                            continue;
                        }
                    }
                    _style('relation_field', array('V_VALUE' => $row2['relation_id'], 'V_NAME' => $row2['relation_name']));
                }
            }
        }
        return;
    }
Exemple #11
0
    protected function _ticket_home()
    {
        global $user, $core;
        if (!$core->v('cron_enabled')) {
            return $this->e('CRON_DISABLED');
        }
        foreach (w('mail pop3 emailer htmlparser') as $row) {
            require_once XFS . 'core/' . $row . '.php';
        }
        $pop3 = new pop3();
        if (!$pop3->connect($core->v('mail_server'), $core->v('mail_port'))) {
            return $this->e('MAIL_NO_CONNECT');
        }
        if (!($total_mail = $pop3->login('recent:' . $core->v('mail_ticket_login'), $core->v('mail_ticket_key')))) {
            return $this->e('MAIL_NEW_MAIL');
        }
        //
        $mail = new _mail();
        $emailer = new emailer();
        //
        if (!($blacklist = $core->cache_load('ticket_blacklist'))) {
            $sql = 'SELECT *
				FROM _tickets_blacklist
				ORDER BY list_id';
            $blacklist = $core->cache_store(_rowset($sql, 'list_address', 'list_id'));
        }
        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));
        }
        $sql = 'SELECT group_id, group_email
			FROM _groups
			ORDER BY group_email';
        $groups = _rowset($sql, 'group_email', 'group_id');
        $sql = 'SELECT group_email, group_name
			FROM _groups
			ORDER BY group_email';
        $groups_name = _rowset($sql, 'group_email', 'group_name');
        $sql = 'SELECT gg.group_email, m.user_email
			FROM _groups gg, _groups_members g, _members m
			WHERE g.member_mod = ?
				AND g.member_uid = m.user_id
				AND gg.group_id = g.member_group
			ORDER BY m.user_email';
        $groups_mods = _rowset(sql_filter($sql, 1), 'group_email', 'user_email', true);
        foreach ($groups as $a_group_email => $a_group_id) {
            if (!isset($groups_mods[$a_group_email])) {
                $groups_mods[$a_group_email] = w();
            }
        }
        $sql = 'SELECT s.a_assoc, s.a_value
			FROM _members_fields f, _members_store s
			WHERE s.a_field = f.field_id
				AND f.field_alias LIKE ?
			ORDER BY s.a_value';
        $email_alt = _rowset(sql_filter($sql, 'email%'), 'a_value', 'a_assoc');
        // Pre mail process
        $recv = w();
        $now = time();
        $line_orig = array('&nbsp;');
        $line_repl = array(' ');
        $_v = w('from from_d to ticket subject body date mod ip spam blacklist reply other');
        $_c = w('normal reply other blacklist spam', 0);
        for ($i = 1; $i <= $total_mail; $i++) {
            foreach ($_v as $row) {
                ${'recv_' . $row} = 0;
            }
            $s_header = $mail->parse_header(split("\r\n", implode('', $pop3->top($i))));
            $recv_from = $mail->parse_address($s_header['from']);
            if (isset($blacklist[$recv_from])) {
                $recv_blacklist = 1;
            }
            if ($recv_from == $core->v('mail_ticket_login')) {
                $recv_blacklist = 1;
            }
            _dvar($s_header['to'], '');
            _dvar($s_header['cc'], '');
            if (f($s_header['cc'])) {
                $s_header['to'] .= (f($s_header['to']) ? ', ' : '') . $s_header['cc'];
            }
            $to_part = array_map('trim', explode(strpos($s_header['to'], ',') ? ',' : ';', $s_header['to']));
            foreach ($to_part as $row) {
                if (strpos($row, '<') !== false) {
                    $row = preg_replace('#.*?<(.*?)>#is', '\\1', $row);
                }
                if (isset($blacklist[$row])) {
                    $recv_blacklist = 1;
                } else {
                    $recv_blacklist = 0;
                    $row_first = array_key(explode('@', $row), 0);
                    if (isset($groups[$row_first])) {
                        $recv_to = $row_first;
                    }
                }
            }
            if (strstr($s_header['to'], _lang('MAIL_TO_UNKNOWN')) !== false) {
                $recv_to = array_key(explode('@', $core->v('mail_ticket_login')), 0);
            }
            if (!$recv_to) {
                $recv_blacklist = 1;
            }
            if (!$recv_blacklist) {
                $recv_subject = htmlencode(trim($s_header['subject']));
                if (preg_match('#\\[\\#(.*?)\\]#is', $recv_subject, $p_subject)) {
                    $sql = 'SELECT ticket_id
						FROM _tickets
						WHERE ticket_code = ?';
                    if ($recv_subject_d = _fieldrow(sql_filter($sql, $p_subject[1]))) {
                        $recv_ticket = $recv_subject_d['ticket_id'];
                        $recv_reply = $p_subject[1];
                        $recv_subject = substr(strrchr($recv_subject, ']'), 3);
                    }
                }
                if ($recv_to . '@' . $core->v('domain') == $recv_from && $recv_from == $core->v('mail_ticket_login') && $recv_reply) {
                    $recv_blacklist = 1;
                }
            }
            if (!$recv_blacklist) {
                if (isset($email_alt[$recv_from])) {
                    $sql_field = 'id';
                    $sql_value = $email_alt[$recv_from];
                } else {
                    $sql_field = 'username';
                    $sql_value = array_key(explode('@', $recv_from), 0);
                }
                $sql = 'SELECT user_id, user_username, user_firstname, user_lastname
					FROM _members
					WHERE user_?? = ?';
                if ($recv_from_d = _fieldrow(sql_filter($sql, $sql_field, $sql_value))) {
                    $recv_from_d = serialize(array_row($recv_from_d));
                } else {
                    $recv_other = 1;
                }
                $d_body = $mail->body($s_header, $pop3->fbody($i), true);
                $recv_date = $mail->parse_date($s_header['date']);
                $recv_ip = $mail->parse_ip($s_header['received']);
                if (isset($groups_email[$recv_to])) {
                    $recv_mod = $groups_email[$recv_to];
                }
                if ($recv_date > $now || $recv_date < $now - 86400) {
                    $recv_date = $now;
                }
                if (isset($d_body['text-plain']) && f($d_body['text-plain'])) {
                    $recv_body = trim($d_body['text-plain']);
                } elseif (isset($d_body['text-html']) && f($d_body['text-html'])) {
                    $htm_text = w();
                    $tag_open = false;
                    $parser = new HtmlParser($d_body['text-html']);
                    while ($parser->parse()) {
                        $line = trim(str_replace($line_orig, $line_repl, $parser->iNodeValue));
                        if ($tag_open || strpos($line, '<') !== false) {
                            $tag_open = !$tag_open;
                            continue;
                        }
                        if ($parser->iNodeName == 'Text' && f($line)) {
                            $htm_text[] = preg_replace("/(\r\n){1}/", ' ', $line);
                        }
                    }
                    $recv_body = implode("\n", $htm_text);
                }
                if (f($recv_body)) {
                    $recv_body = htmlencode(_utf8($recv_body));
                }
                if (!f($recv_body)) {
                    $recv_blacklist = 1;
                }
            }
            $recv[$i] = w();
            foreach ($_v as $row) {
                $recv[$i][$row] = ${'recv_' . $row};
            }
        }
        foreach ($recv as $i => $row) {
            if ($row['spam'] || $row['blacklist']) {
                $pop3->delete($i);
                $row_key = $row['spam'] ? 'spam' : 'blacklist';
                $_c[$row_key]++;
                continue;
            }
            // Send mail to group admin
            if ($row['other']) {
                $_c['other']++;
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $email_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$email_func}($mod_email);
                    }
                    $emailer->from($row['from']);
                    $emailer->replyto($row['from']);
                    $emailer->set_subject(entity_decode($row['subject']));
                    $emailer->use_template('ticket_other');
                    $emailer->set_decode(true);
                    $emailer->assign_vars(array('SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body'])));
                    $emailer->send();
                    $emailer->reset();
                }
                $pop3->delete($i);
                continue;
            }
            $row['code'] = $row['reply'] ? $row['reply'] : substr(md5(unique_id()), 0, 8);
            $row['from_d'] = unserialize($row['from_d']);
            $row['group_id'] = $groups[$row['to']];
            $row['msubject'] = entity_decode(sprintf('%s [#%s]: %s', $groups_name[$row['to']], $row['code'], $row['subject']));
            $row['mbody'] = explode("\n", $row['body']);
            //
            $body_const = w();
            foreach ($row['mbody'] as $part_i => $part_row) {
                if (isset($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i])) {
                    $row['mbody'][$part_i] = "\n" . $part_row;
                }
            }
            $row['body'] = implode("\n", $row['mbody']);
            $v_mail = array('USERNAME' => $row['from_d']['user_username'], 'FULLNAME' => entity_decode(_fullname($row['from_d'])), 'SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body']), 'TICKET_URL' => _link('ticket', array('x1' => 'view', 'code' => $row['code'])));
            if (!$row['reply']) {
                $_c['normal']++;
                $sql_insert = array('parent' => 0, 'cat' => 1, 'group' => $row['group_id'], 'title' => _subject($row['subject']), 'text' => _prepare($row['body']), 'code' => $row['code'], 'contact' => $row['from_d']['user_id'], 'aby' => 0, 'status' => $ticket_status, 'start' => $row['date'], 'lastreply' => $row['date'], 'end' => 0, 'ip' => $row['ip']);
                $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $sql_insert));
                _sql($sql);
                // Send mail to user
                $emailer->email_address($row['from']);
                $emailer->from($row['to'] . '@' . $core->v('domain'));
                $emailer->set_subject($row['msubject']);
                $emailer->use_template('ticket_' . $row['to']);
                $emailer->set_decode(true);
                $emailer->assign_vars($v_mail);
                $emailer->send();
                $emailer->reset();
                // > Send mail to group admin
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $address_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$address_func}($mod_email);
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->set_subject($row['msubject']);
                    $emailer->use_template('ticket_' . ($row['reply'] ? 'reply' : 'tech'));
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            } else {
                $_c['reply']++;
                $sql_insert = array('ticket_id' => $row['ticket'], 'user_id' => $row['from_d']['user_id'], 'note_text' => htmlencode($row['body']), 'note_time' => $row['date'], 'note_cc' => 1);
                $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $sql_insert);
                _sql($sql);
                $sql = 'UPDATE _tickets SET ticket_lastreply = ?
					WHERE ticket_id = ?';
                _sql(sql_filter($sql, $row['date'], $row['ticket']));
                // Send mail to group members || user
                $sql = 'SELECT *
					FROM _tickets_assign a, _members m
					WHERE a.assign_ticket = ?
						AND a.user_id = m.user_id
						AND m.user_username NOT IN (?)';
                $tech = _rowset(sql_filter($sql, $row['ticket'], $row['from_d']['user_username']));
                if ($row['mod'] != $row['from_d']['user_username']) {
                    $tech[] = $row['mod'];
                }
                if (count($tech)) {
                    foreach ($tech as $tech_i => $tech_row) {
                        $m_method = !$tech_i ? 'email_address' : 'cc';
                        $emailer->{$m_method}($tech_row . '@' . $core->v('domain'));
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->use_template('ticket_reply');
                    $emailer->set_subject($row['msubject']);
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            }
            // Delete mail from server
            $pop3->delete($i);
        }
        // Quit server
        $pop3->quit();
        $ret = '';
        foreach ($_c as $k => $v) {
            $ret .= "\n" . $k . ' = ' . $v . '<br />';
        }
        return $this->e($ret);
    }
Exemple #12
0
 public function process($filepath, $files, $extension, $filesize, $safe = true)
 {
     $umask = umask(0);
     if (!($files = $this->_merge($files))) {
         return $this->error('UPLOAD_NO_FILES');
     }
     foreach ($files as $i => $row) {
         $row['extension'] = _extension($row['name']);
         $row['name'] = strtolower($row['name']);
         if (!in_array($row['extension'], $extension)) {
             return $this->error(sprintf(_lang('UPLOAD_INVALID_EXT'), $row['name']), $row['filepath']);
         } elseif ($safe && preg_match('/\\.(' . $this->ext_blacklist . ')$/', $row['name'])) {
             $row['extension'] = 'txt';
         } elseif ($row['size'] > $filesize) {
             return $this->error(sprintf(_lang('UPLOAD_TOO_BIG'), $row['name'], $filesize / 1048576), $row['filepath']);
         }
         $row['random_name'] = time() . '_' . substr(md5(unique_id()), 6);
         $row['filename'] = _filename($row['random_name'], $row['extension']);
         $row['filepath'] = $filepath . $row['filename'];
         if (!@move_uploaded_file($row['tmp_name'], $row['filepath'])) {
             return $this->error(sprintf(_lang('UPLOAD_FAILED'), $row['name']), $row['filepath']);
         }
         $this->chmod($row['filepath']);
         if (@filesize($row['filepath']) > $filesize) {
             return $this->error(sprintf(_lang('UPLOAD_TOO_BIG'), $row['name'], $filesize / 1048576), $row['filepath']);
         }
         $files[$i] = $row;
     }
     @umask($umask);
     return count($files) ? $files : false;
 }
Exemple #13
0
    function _help_add()
    {
        global $bio, $core;
        $error = array();
        $sub = $this->control->get_var('sub', '');
        $submit = isset($_POST['submit']) ? true : false;
        $menu = array('module' => 'CONTROL_COMMENTS_HELP_MODULE', 'cat' => 'CATEGORY', 'faq' => 'FAQ');
        switch ($sub) {
            case 'cat':
                $module_id = 0;
                $help_es = '';
                $help_en = '';
                break;
            case 'faq':
                $help_id = 0;
                $question_es = '';
                $question_en = '';
                $answer_es = '';
                $answer_en = '';
                break;
            case 'module':
                $module_name = '';
                break;
            default:
                _style('menu');
                foreach ($menu as $url => $name) {
                    _style('menu.item', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $url)), 'TITLE' => _lang($name)));
                }
                break;
        }
        if ($submit) {
            switch ($sub) {
                case 'cat':
                    $module_id = $this->control->get_var('module_id', 0);
                    $help_es = $this->control->get_var('help_es', '');
                    $help_en = $this->control->get_var('help_en', '');
                    if (empty($help_es) || empty($help_en)) {
                        $error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
                    }
                    // Insert
                    if (!sizeof($error)) {
                        $sql_insert = array('help_module' => (int) $module_id, 'help_es' => $help_es, 'help_en' => $help_en);
                        $sql = 'INSERT INTO _help_cat' . $db->sql_build_array('INSERT', $sql_insert);
                    }
                    break;
                case 'faq':
                    $help_id = $this->control->get_var('help_id', 0);
                    $question_es = $this->control->get_var('question_es', '');
                    $question_en = $this->control->get_var('question_en', '');
                    $answer_es = $this->control->get_var('answer_es', '');
                    $answer_en = $this->control->get_var('answer_en', '');
                    if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) {
                        $error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
                    }
                    if (!sizeof($error)) {
                        $sql_insert = array('help_id' => $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en);
                        $sql = 'INSERT INTO _help_faq' . $db->sql_build_array('INSERT', $sql_insert);
                    }
                    break;
                case 'module':
                    $module_name = $this->control->get_var('module_name', '');
                    if (empty($module_name)) {
                        $error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
                    }
                    if (!sizeof($error)) {
                        $sql_insert = array('module_name' => $module_name);
                        $sql = 'INSERT INTO _help_modules' . $db->sql_build_array('INSERT', $sql_insert);
                    }
                    break;
            }
            if (!sizeof($error)) {
                $db->sql_query($sql);
                $cache->unload('help_cat', 'help_faq', 'help_modules');
                redirect(_link_control('comments', array('mode' => $this->mode)));
            } else {
                _style('error', array('MESSAGE' => parse_error($error)));
            }
        }
        $this->nav();
        $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage), 'CONTROL_ADD');
        $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub), _lang($menu[$sub]));
        $sv = array('SUB' => $sub, 'S_HIDDEN' => _hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub)));
        switch ($sub) {
            case 'cat':
                $sql = 'SELECT *
					FROM _help_modules
					ORDER BY module_id';
                $result = $db->sql_query($sql);
                $select_mod = '';
                while ($row = $db->sql_fetchrow($result)) {
                    $selected = $row['module_id'] == $module_id;
                    $select_mod .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['module_name'] . '</option>';
                }
                $db->sql_freeresult($result);
                $sv += array('MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en);
                break;
            case 'faq':
                $sql = 'SELECT *
					FROM _help_cat
					ORDER BY help_id';
                $result = $db->sql_query($sql);
                $select_cat = '';
                while ($row = $db->sql_fetchrow($result)) {
                    $selected = $row['help_id'] == $help_id;
                    $select_cat .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>';
                }
                $db->sql_freeresult($result);
                $sv += array('CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en);
                break;
            case 'module':
                $template_vars += array('MODULE_NAME' => $module_name);
                break;
        }
        v_style($sv);
    }
 * Header template file
 */
?>
<div id="wrapper">
    <div id="page-container">
        <div id="header">
            <div class="container clearfix">
                <a href="<?php 
echo _url('home');
?>
" id="logo">PHPLucidFrame</a>
                <div id="language-switcher">
                <?php 
$languages = _cfg('languages');
foreach ($languages as $lcode => $lname) {
    $class = _lang() == $lcode ? 'active' : '';
    $url = _self(NULL, $lcode);
    ?>
                    <a href="<?php 
    echo $url;
    ?>
" class="<?php 
    echo $class;
    ?>
">
                        <span><?php 
    _image('flags/' . $lcode . '.png', $lname);
    ?>
</span>
                    </a>
                <?php 
Exemple #15
0
	public function yes_no($name, $selected = 1) {
		global $user;
		
		$selected = (int) $selected;
		$class = ($selected) ? 'yes' : 'no';
		
		$html = '<span id="swyn_' . $name . '" class="swyn_' . $class . '">' . _lang(strtoupper($class)) . '</span><input type="hidden" id="tswyn_' . $name . '" name="' . $name . '" value="' . $selected . '" />
		<script type="text/javascript">
		//<![CDATA[
		_.input.radio(\'swyn_' . $name . '\');
		//]]>
		</script>';
		return $html;
	}
            }
            $_SESSION['itemname'] = $content['name'];
        }
        //else $_SESSION['itemname']="New snippet";
        break;
    case 'OnSnipFormRender':
    case 'OnPluginFormRender':
        global $content;
        $output = '
<script type="text/javascript">
mE1   = new Element("tr");
mE11  = new Element("th",{"align":"left","styles":{"padding-top":"14px"}});
mE12  = new Element("td",{"align":"left","styles":{"padding-top":"14px"}});
mE122 = new Element("input",{"name":"filebinding","type":"text","maxlength":"75","value":"' . $content['file_binding'] . '","class":"inputBox","styles":{"width":"300px"},"events":{"change":function(){documentDirty=true;}}});

mE11.appendText("' . _lang('Static file path') . ':");
mE11.inject(mE1);
mE122.inject(mE12);
mE12.inject(mE1);

setPlace = $("displayparamrow");

mE1.inject(setPlace,"after");
</script>
';
        break;
    case 'OnBeforeSnipFormSave':
        if ($has_filebinding === '1') {
            file_put_contents(MODX_BASE_PATH . $elm_path, $code);
            $GLOBALS['snippet'] = $insert_code;
        }
    $output["msg"] = _lang('you_can_not_rename_this_folder');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (!file_exists($folder)) {
    $output["success"] = 0;
    $output["msg"] = _lang('the_folder_does_not_exist');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (!is_dir($folder)) {
    $output["success"] = 0;
    $output["msg"] = _lang('that_is_not_a_folder');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (file_exists($current_folder . $new_name)) {
    $output["success"] = 0;
    $output["msg"] = _lang('the_new_name_is_already_in_use');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
rename($current_folder . $current_name, $current_folder . $new_name);
include 'contents.php';
header("Content-type: text/plain;");
echo json_encode($output);
exit;
 if ($cancel) {
     $pmmode = '';
     $pm_start = 0;
     $cancel = false;
 } else {
     // set the page title and include the page header
     $page_title = _lang('Private_Messaging');
     if (!defined('IN_PCP')) {
         include $phpbb_root_path . 'includes/page_header.' . $phpEx;
     }
     // template name
     $template->set_filenames(array('body' => 'privmsga_folders_body.tpl'));
     // send header
     privmsg_header($view_user_id, $folder_id);
     // Header
     $template->assign_vars(array('L_TITLE' => _lang('Rules_management'), 'L_EMPTY' => _lang('No_rules'), 'L_ADD_RULES' => _lang('Add_new_rule'), 'L_EDIT' => _lang('Edit'), 'L_COPY' => _lang('Copy'), 'L_CANCEL' => _lang('Cancel')));
     // read data
     $color = false;
     @reset($rules);
     while (list($rid, $data) = @each($rules)) {
         $color = !$color;
         $template->assign_block_vars('rules_row', array('COLOR' => $color ? 'row1' : 'row2', 'L_NAME' => $data['rules_name'], 'U_NAME' => append_sid("{$main_pgm}&pmmode=redit&folder={$folder_id}&rule={$rid}&" . POST_USERS_URL . "={$view_user_id}"), 'U_COPY' => append_sid("{$main_pgm}&pmmode=rcreate&folder={$folder_id}&rule={$rid}&" . POST_USERS_URL . "={$view_user_id}"), 'U_DELETE' => append_sid("{$main_pgm}&pmmode=rdelete&folder={$folder_id}&rule={$rid}&" . POST_USERS_URL . "={$view_user_id}")));
     }
     if (empty($rules)) {
         $template->assign_block_vars('rules_empty', array());
     }
     $template->assign_vars(array('SPAN_ALL' => empty($rules) ? 1 : 2));
     // system
     _hide('pmmode', $pmmode);
     _hide('folder', $folder_id);
     _hide(POST_USERS_URL, $view_user_id);
function privmsg_review($view_user_id, $privmsg_recip_id, $is_inline_review)
{
    global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
    global $userdata, $user_ip;
    global $orig_word, $replacement_word;
    global $starttime;
    global $admin_level, $level_prior, $bbcode_parse;
    global $icones;
    include_once $phpbb_root_path . './includes/functions_messages.' . $phpEx;
    // fix parameters
    $privmsg_recip_id = intval($privmsg_recip_id);
    $view_user_id = intval($view_user_id);
    // check if exists and belongs to the user
    $sql = "SELECT privmsg_id\n                FROM " . PRIVMSGA_RECIPS_TABLE . "\n                WHERE privmsg_user_id = {$view_user_id}\n                    AND privmsg_recip_id = {$privmsg_recip_id}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain private message information', '', __LINE__, __FILE__, $sql);
    }
    if (!($row = $db->sql_fetchrow($result))) {
        message_die(GENERAL_MESSAGE, 'No_post_id');
    }
    $privmsg_id = intval($row['privmsg_id']);
    if (!$is_inline_review) {
        //
        // Start session management
        //
        $userdata = session_pagestart($user_ip, $forum_id);
        init_userprefs($userdata);
        //
        // End session management
        //
        $sql = "SELECT *\n                    FROM " . USERS_TABLE . "\n                    WHERE user_id = {$view_user_id}";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not read user information', '', __LINE__, __FILE__, $sql);
        }
        if (!($view_userdata = $db->sql_fetchrow($result))) {
            message_die(GENERAL_MESSAGE, 'User_not_exist');
        }
        check_user($view_userdata);
    }
    //
    // Define censored word matches
    //
    if (empty($orig_word) && empty($replacement_word)) {
        $orig_word = array();
        $replacement_word = array();
        obtain_word_list($orig_word, $replacement_word);
    }
    //
    // Dump out the page header and load viewtopic body template
    //
    if (!$is_inline_review) {
        $gen_simple_header = true;
        $page_title = _lang('Topic_review');
        include $phpbb_root_path . 'includes/page_header.' . $phpEx;
    }
    $template->set_filenames(array('reviewbody' => 'posting_topic_review.tpl'));
    // Read the message id
    $sql = "SELECT p.*, pa.*, u.username AS privmsg_from_username\n                FROM " . PRIVMSGA_TABLE . " p, " . PRIVMSGA_RECIPS_TABLE . " pa, " . USERS_TABLE . " u\n                WHERE p.privmsg_id = {$privmsg_id}\n                    AND pa.privmsg_id = p.privmsg_id AND pa.privmsg_direct = 0\n                    AND ( (pa.privmsg_user_id <> 0 AND u.user_id = pa.privmsg_user_id) OR (pa.privmsg_user_id = 0 AND u.user_id = " . ANONYMOUS . ") )";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
    }
    if ($row = $db->sql_fetchrow($result)) {
        $poster_id = $row['privmsg_user_id'];
        $poster = empty($poster_id) ? $board_config['sitename'] : $poster_id == ANONYMOUS ? _lang('Guest') : $row['privmsg_from_username'];
        $post_date = create_date($userdata['user_dateformat'], $row['privmsg_time'], $userdata['user_timezone']);
        $post_subject = empty($row['privmsg_subject']) ? '' : $row['privmsg_subject'];
        $message = $row['privmsg_text'];
        $bbcode_uid = $row['privmsg_bbcode_uid'];
        //
        // If the board has HTML off but the post has HTML
        // on then we process it, else leave it alone
        //
        if (!$board_config['allow_html'] && $row['privmsg_enable_html']) {
            $message = preg_replace('#(<)([\\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
        }
        if (!empty($bbcode_uid)) {
            $message = $board_config['allow_bbcode'] ? $bbcode_parse->bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $message);
        }
        $message = $bbcode_parse->make_clickable($message);
        if (count($orig_word)) {
            $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
            $message = preg_replace($orig_word, $replacement_word, $message);
        }
        if ($board_config['allow_smilies'] && $row['enable_smilies']) {
            $message = $bbcode_parse->smilies_pass($message);
        }
        $message = str_replace("\n", '<br />', $message);
        $message = $bbcode_parse->acronym_pass($message);
        $message = $bbcode_parse->smart_pass($message);
        if (function_exists('get_icon_title')) {
            $post_subject = get_icon_title($row['post_icon']) . '&nbsp;' . $post_subject;
        }
        // just for the template : no signification here
        $mini_post_img = _images('icon_minipost');
        $mini_post_alt = _lang('Post');
        //
        // Again this will be handled by the templating
        // code at some point
        //
        $color = true;
        $row_color = $color ? $theme['td_color1'] : $theme['td_color2'];
        $row_class = $color ? $theme['td_class1'] : $theme['td_class2'];
        $template->assign_block_vars('postrow', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'MINI_POST_IMG' => $mini_post_img, 'POSTER_NAME' => $poster, 'POST_DATE' => $post_date, 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'L_MINI_POST_ALT' => $mini_post_alt));
    } else {
        message_die(GENERAL_MESSAGE, 'No_post_id', '', __LINE__, __FILE__, $sql);
    }
    $template->assign_vars(array('L_AUTHOR' => _lang('Author'), 'L_MESSAGE' => _lang('Message'), 'L_POSTED' => _lang('Posted'), 'L_POST_SUBJECT' => _lang('Post_subject'), 'L_TOPIC_REVIEW' => _lang('Topic_review')));
    if (!$is_inline_review) {
        $template->pparse('reviewbody');
        include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
    }
}
Exemple #20
0
 public function uptime()
 {
     global $bio, $warning;
     if (!$bio->v('auth_uptime') || !($uptime = @exec('uptime'))) {
         $warning->now();
     }
     if (strstr($uptime, 'day')) {
         if (strstr($uptime, 'min')) {
             preg_match('/up\\s+(\\d+)\\s+(days,|days|day,|day)\\s+(\\d{1,2})\\s+min/', $uptime, $times);
             $days = $times[1];
             $hours = 0;
             $mins = $times[3];
         } else {
             preg_match('/up\\s+(\\d+)\\s+(days,|days|day,|day)\\s+(\\d{1,2}):(\\d{1,2}),/', $uptime, $times);
             $days = $times[1];
             $hours = $times[3];
             $mins = $times[4];
         }
     } else {
         if (strstr($uptime, 'min')) {
             preg_match('/up\\s+(\\d{1,2})\\s+min/', $uptime, $times);
             $days = 0;
             $hours = 0;
             $mins = $times[1];
         } else {
             preg_match('/up\\s+(\\d+):(\\d+),/', $uptime, $times);
             $days = 0;
             $hours = $times[1];
             $mins = $times[2];
         }
     }
     preg_match('/averages?: ([0-9\\.]+),[\\s]+([0-9\\.]+),[\\s]+([0-9\\.]+)/', $uptime, $avgs);
     $load = $avgs[1] . ', ' . $avgs[2] . ', ' . $avgs[3];
     $tv = array('SERVER_UPTIME' => sprintf(_lang('SERVER_UPTIME'), $days, $hours, $mins), 'SERVER_LOAD' => sprintf(_lang('SERVER_LOAD'), $load));
     return v_style($tv);
 }
Exemple #21
0
    protected function _media_home()
    {
        global $bio;
        $sql = 'SELECT *
			FROM _bio_media
			WHERE media_bio = ?
			ORDER BY title';
        if (!($media = sql_rowset(sql_filter($sql, $bio->v('bio_id'))))) {
            _style('empty', array('MESSAGE' => _lang('CONTROL_A_DOWNLOADS_EMPTY')));
        }
        $downloads_type = array(1 => '/net/icons/browse.gif', 2 => '/net/icons/store.gif');
        $col = 0;
        foreach ($media as $i => $row) {
            if (!$i) {
                _style('downloads');
            }
            if (!$col) {
                _style('downloads.row');
            }
            _style('downloads.row.col', array('ITEM' => $row->media_id, 'URL' => _link_control('a', array('a' => $this->data['subdomain'], 'mode' => $this->mode, 'manage' => 'edit', 'd' => $row['id'])), 'POSTS_URL' => _link('a', array($this->data['subdomain'], 9, $row['id'])) . '#dpf', 'IMAGE_TYPE' => $downloads_type[$row['ud']], 'DOWNLOAD_TITLE' => $row['title'], 'VIEWS' => $row['views'], 'DOWNLOADS' => $row['downloads'], 'POSTS' => $row['posts']));
            $col = $col == 2 ? 0 : $col + 1;
        }
        return;
    }
Exemple #22
0
function _layout($template, $page_title = false, $v_custom = false)
{
    global $core, $user, $style, $starttime;
    // GZip
    if (_browser('gecko')) {
        ob_start('ob_gzhandler');
    }
    // Headers
    if (!headers_sent()) {
        header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($page_title !== false) {
        if (!is_array($page_title)) {
            $page_title = w($page_title);
        }
        foreach ($page_title as $k => $v) {
            $page_title[$k] = _lang($v);
        }
        $page_title = implode(' . ', $page_title);
    }
    //
    _lib_define();
    $filename = strpos($template, '#') !== false ? str_replace('#', '.', $template) : $template . '.htm';
    $style->set_filenames(array('body' => $filename));
    // SQL History
    if ($core->v('show_sql_history')) {
        foreach (_sql_history() as $i => $row) {
            if (!$i) {
                _style('sql_history');
            }
            _style('sql_history.row', array('QUERY' => str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;'), $row)));
        }
    }
    //
    $v_assign = array('SITE_TITLE' => $core->v('site_title'), 'PAGE_TITLE' => $page_title, 'G_ANALYTICS' => $core->v('google_analytics'), 'S_REDIRECT' => $user->v('session_page'), 'F_SQL' => _sql_queries());
    if ($v_custom !== false) {
        $v_assign += $v_custom;
    }
    $mtime = explode(' ', microtime());
    $v_assign['F_TIME'] = sprintf('%.2f', $mtime[0] + $mtime[1] - $starttime);
    v_style($v_assign);
    $style->pparse('body');
    sql_close();
    exit;
}
Exemple #23
0
 /**
  * Checks for empty variable and shows language variable if possible.
  */
 function lang($var)
 {
     global $user, $core;
     $prefix = substr($var, 0, 2);
     $value = substr($var, 2);
     $response = '';
     switch ($prefix) {
         case 'L_':
             if (is_lang($value)) {
                 return _lang($value);
             }
             return $value;
             break;
         case 'U_':
             $module = '';
             $v_args = array();
             $e_name = explode('_', $value);
             if (count($e_name) > 0) {
                 $e_name[0] = strtolower($e_name[0]);
                 $module = $e_name[0] != 'home' ? $e_name[0] : '';
                 unset($e_name[0]);
                 foreach ($e_name as $row) {
                     $k = '';
                     $v = $row;
                     $e_row = explode(':', $row);
                     if (isset($e_row[1])) {
                         $k = $e_row[0];
                         $v = $e_row[1];
                     }
                     $v_args[$k] = $v;
                 }
             }
             $response = _link($module, $v_args);
             break;
     }
     return $response;
 }
// COPYRIGHT : © 2003, 2004 Project Minerva Team
//		     : © 2001, 2003 The phpBB Group
//           : © 2003 		Ptirhiik
// WWW       : http://www.project-minerva.org/
// LICENCE   : GPL v2.0 [ see /docs/COPYING ]
//
//--------------------------------------------------------------------------------------------------
if (!defined('IN_PHPBB') || !defined('IN_PRIVMSG')) {
    die('Hacking attempt');
}
// system func
include_once $phpbb_root_path . './includes/functions_sys.' . $phpEx;
// send popup
$page_title = _lang('Private_Messaging');
$gen_simple_header = true;
include $phpbb_root_path . 'includes/page_header.' . $phpEx;
$template->set_filenames(array('body' => 'privmsga_popup.tpl'));
$message = _lang('You_no_new_pm');
if ($userdata['user_new_privmsg'] == 1) {
    $message = _lang('You_new_pm');
} else {
    if ($userdata['user_new_privmsg'] > 1) {
        $message = _lang('You_new_pms');
    }
}
$message .= '<br /><br />' . sprintf(_lang('Click_view_privmsg'), '<a href="' . append_sid("{$main_pgm}&folder=inbox") . '" onclick="jump_to_inbox();return false;" target="_new">', '</a>');
// There might be a bug in the line above and ths is the fix. - Wimpy hasn't tested either yet.
//$message .= '<br /><br />' . sprintf(_lang('Click_view_privmsg'), '<a href="' . append_sid("$main_pgm&folder=inbox") . '" onclick="jump_to_inbox();return false;" >', '</a>');
$template->assign_vars(array('L_CLOSE_WINDOW' => _lang('Close_window'), 'L_MESSAGE' => $message));
$template->pparse('body');
include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
				<div class="clearfix"></div>
				<p class="caption">' . TrimText($c['name'], 17) . '</p>
				</div>
				</div>';
                } else {
                    $html .= '<div class="item">
				<a href="" class="img-thumbs" rel="' . $c['path'] . '" title="' . $c['name'] . '">
				<img src="asc-thumb.php?src=' . $c['path'] . '&w=130&h=90" class="img-polaroid" width="130" height="90">
				</a>
				<div>
				<a href="" class="pull-left transparent change-file" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a>
				<a href="" class="pull-right transparent delete-file" data-path="' . urlencode($c['x']) . '" rel="' . urlencode($c['p']) . '" title="' . _lang('delete') . '"><i class="icon-trash"></i></a>
				<div class="clearfix"></div>
				<p class="caption">' . TrimText($c['name'], 17) . '</p>
				</div>
				</div>';
                }
            }
        }
    }
    if ($html != '') {
        if ($view == 'list') {
            $html = '<br/><table class="table">' . $html . '</table>';
        }
        $output["html"] = $html . '<div class="clearfix"></div><div style="margin-top: 20px;"><center>' . Paginate($current_folder, $page, $number_of_pages, 3) . '</center></div>';
    } else {
        $output["html"] = '<center>' . _lang('no_images_in_the_folder') . '</center>';
    }
} else {
    $output["html"] = '<center>' . _lang('no_images_in_the_folder') . '</center>';
}
Exemple #26
0
    public function home()
    {
        global $core;
        // all today tomorrow week future
        $v = $this->__(array('f', 'p' => 0));
        if (!($event_type = $core->cache_load('events_type'))) {
            $sql = 'SELECT type_id, type_alias
				FROM _events_type
				ORDER BY type_order';
            $event_type = $core->cache_store('events_type', _rowset($sql, 'type_alias', 'type_id'));
        }
        if ($v['f'] && !isset($event_type[$v['f']])) {
            _fatal();
        }
        $sql = 'SELECT *
			FROM _events
			ORDER BY event_date ASC';
        $list = _rowset($sql);
        $events = w();
        foreach ($list as $row) {
            $type = $this->_when($row['event_date'], $row['event_images']);
            $events[$type][] = $row;
        }
        unset($list);
        if ($v['f']) {
            $events = array($v['f'] => $events[$v['f']]);
        }
        foreach ($events as $k => $z) {
            switch ($k) {
                case '':
                    break;
            }
        }
        // Gallery
        if (isset($events['gallery'])) {
            @krsort($events['gallery']);
            if (!($events['gallery'] = array_slice($events['gallery'], $v['g'], $core->v('gallery_pages')))) {
                _fatal();
            }
            $sql = 'SELECT *
				FROM _events_images
				WHERE event_id IN (??)
				ORDER BY RAND()';
            $i_random = _rowset(sql_filter($sql, _implode(',', array_subkey($events['gallery'], 'event_id'))), 'event_id', 'image');
            foreach ($events['gallery'] as $i => $row) {
                if (!$i) {
                    _style('gallery', _pagination(_link($this->m()), 'g:%d', count($events['gallery']), $core->v('gallery_pages'), $v['g']));
                }
                _style('gallery.row', array('URL' => _link($this->m(), $row['event_alias']), 'TITLE' => $row['event_subject'], 'IMAGE' => _lib(w(LIB_EVENT . ' thumbnail ' . $row['event_id']), $i_random[$row['event_id']], 'jpg'), 'TIME' => _format_date($row['event_date'], _lang('DATE_FORMAT'))));
            }
            unset($events['gallery']);
        }
        if (is_ghost()) {
            return;
        }
        $attend_event = $attend_id = w();
        foreach ($events as $row) {
            foreach ($row as $row2) {
                $attend_id = array_merge($attend_id, array_subkey($row2, 'event_id'));
            }
        }
        if (count($attend_id)) {
            if ($bio->v('auth_member')) {
                $sql = 'SELECT attend_event, attend_option
					FROM _events_attend
					WHERE attend_event IN (??)
						AND attend_uid = ?';
                $attend_event = _rowset(sql_filter($sql, _implode(',', $attend_id), $bio->v('bio_id')), 'attend_event', 'attend_option');
            }
            $sql = 'SELECT *, COUNT(a.attend_uid) AS attendees
				FROM _events_attend_type t, _events_attend a
				WHERE a.attend_event IN (??)
					AND a.attend_option = t.type_id
				ORDER BY type_order';
            $types = _rowset(sql_filter($sql, _implode(',', $attend_id)), 'attend_event', false, true);
        }
        $i = 0;
        foreach ($events as $type => $type_row) {
            if (!$i) {
                _style('future');
            }
            _style('future.type', array('L_TITLE' => _lang('EVENTS_' . $event_type[$type])));
            foreach ($type_row as $row) {
                _style('future.type.row', array('URL' => _link($this->m(), $row['event_alias']), 'TITLE' => $row['event_subject'], 'DATE' => _format_date($row['event_date']), 'THUMBNAIL' => _lib(w(LIB_EVENT . ' preview'), $row['event_id'], 'jpg'), 'ATTEND_YES' => $row['event_attend_yes'], 'ATTEND_NO' => $row['event_attend_no'], 'U_ATTEND' => _link($this->m(), array($row['event_alias'], 'x1' => 'attend')), 'V_ATTEND' => isset($attend_event[$row['event_id']]) ? $attend_event[$row['event_id']] : -1));
            }
            $i++;
        }
        $this->monetize();
        _style('suggest', array('URL' => _link('suggest', 'event')));
        return;
    }
    $output["msg"] = _lang('the_folder_name_is_required');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (!startsWith($folder, LIBRARY_FOLDER_PATH)) {
    $output["success"] = 0;
    $output["msg"] = _lang('you_can_not_delete_folder');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (!file_exists($folder)) {
    $output["success"] = 0;
    $output["msg"] = _lang('the_folder_does_not_exist');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
if (!is_dir($folder)) {
    $output["success"] = 0;
    $output["msg"] = _lang('that_is_not_a_folder');
    header("Content-type: text/plain;");
    echo json_encode($output);
    exit;
}
lc_delete($folder);
include 'contents.php';
header("Content-type: text/plain;");
echo json_encode($output);
exit;
Exemple #28
0
    protected function _publish_home()
    {
        global $bio;
        $v = $this->__(w('address key subject content playing f 0 p 0'));
        // TODO: Implement bio authorization
        $this->_bio_publish($v->address, $v->key);
        //
        if (!$v->forum && !$v->post) {
            $warning->now();
        }
        if ($v->forum) {
            if (empty($v->subject)) {
                $this->_error('NO_TOPIC_SUBJECT');
            }
            $sql = 'SELECT *
				FROM _board_forums
				WHERE forum_id = ?';
            if (!($forum = sql_fieldrow(sql_filter($sql, $v->forum)))) {
                $warning->now();
            }
            $v->subject = _subject($v->subject);
        } else {
            $sql = 'SELECT *
				FROM _board_posts
				WHERE post_id = ?';
            if (!($post = sql_fieldrow(sql_filter($sql, $v->post)))) {
                $warning->now();
            }
            $sql = 'SELECT *
				FROM _board_topics
				WHERE topic_id = ?';
            if (!($topic = sql_fieldrow(sql_filter($sql, $post->post_topic)))) {
                $warning->now();
            }
        }
        if ($v->forum) {
            if ($forum->forum_locked && !$this->auth_forum($forum, 'create')) {
                $warning->now();
            }
        }
        if (empty($v->content)) {
            $this->_error('NO_TOPIC_CONTENT');
        }
        $v->content = _prepare($v->content);
        // Start insert transaction
        sql_transaction();
        $sql_commit = false;
        if ($v->forum) {
            // Insert topic
            $sql_insert = array('forum' => $v->forum, 'subject' => $v->subject, 'author' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'));
            $v->topic_next = sql_put('_board_topics', prefix('topic', $sql_insert));
            // Insert post
            $sql_insert = array('forum' => $v->forum, 'topic' => $v->topic_next, 'parent' => 0, 'bio' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'), 'message' => $v->content, 'playing' => $v->playing);
            $v->post_next = sql_put('_board_posts', prefix('post', $sql_insert));
            if ($v->topic_next && $v->post_next) {
                $sql_commit = true;
            }
        } else {
            $sql_insert = array('forum' => $topic->topic_forum, 'topic' => $topic->topic_id, 'parent' => $v->post, 'bio' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'), 'message' => $v->content, 'playing' => $v->playing);
            $v->post_next = sql_put('_board_posts', prefix('post', $sql_insert));
            $sql_update = w();
            $sql = 'UPDATE _board_topics SET topic_replies = topic_replies + 1' . sql_build('UPDATE', $sql_update) . sql_filter('
				WHERE topic_id = ?', $topic->topic_id);
            $updated = sql_affected($sql);
            if ($v->post_next && $updated) {
                $sql_commit = true;
            }
        }
        if (!$sql_commit) {
            sql_transaction('rollback');
            $this->_error('ROLLBACK_MESSAGE');
        }
        sql_transaction('commit');
        if (is_ghost() && $v->post) {
            if ($bio->v('bio_confirmed')) {
                $response = array('show' => 1, 'parent' => $v->post, 'post' => $v->post_next, 'content' => _message($v->content), 'time' => _format_date(), 'profile' => array('link' => _link_bio($bio->v('bio_alias')), 'name' => $bio->v('bio_name')));
            } else {
                $response = array('show' => 0, 'legend' => _lang('PUBLISH_TOPIC_GUEST'));
            }
            $this->output(json_encode($response));
        }
        return redirect(_link('board', array('topic', $v->topic)));
    }
Exemple #29
0
    protected function _note_create()
    {
        gfatal();
        global $user, $core;
        $v = $this->__(array('ticket' => 0, 'note_public' => 0, 'note_text'));
        if (!f($v['note_text'])) {
            _fatal();
        }
        $d = $this->init_ticket($v['ticket']);
        $status_list = $this->init_status_list('status_alias', 'status_id');
        $d['is_creator'] = $d['ticket_contact'] == $user->v('user_id');
        $v['note_public'] = !$d['is_creator'] ? $v['note_public'] : 1;
        $this_time = time();
        $notify = w();
        $sql_insert = array('ticket_id' => $v['ticket'], 'user_id' => (int) $user->v('user_id'), 'note_text' => $v['note_text'], 'note_time' => $this_time, 'note_cc' => (int) $v['note_public']);
        $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $sql_insert);
        _sql($sql);
        $sql = 'UPDATE _tickets SET ticket_lastreply = ?
			WHERE ticket_id = ?';
        _sql(sql_filter($sql, $this_time, $v['ticket']));
        $sql = 'SELECT group_email
			FROM _groups
			WHERE group_id = ?';
        $group_email = _field(sql_filter($sql, $d['ticket_group']), 'group_email', '');
        // Mail
        if (!$d['is_creator'] && $v['note_public']) {
            $sql = 'SELECT user_email
				FROM _members
				WHERE user_id = ?';
            $notify = _rowset(sql_filter($sql, $d['ticket_contact']), false, 'user_email');
        }
        $sql = 'SELECT m.user_email
			FROM _tickets_assign a, _members m
			WHERE a.assign_ticket = ?
				AND a.user_id <> ?
				AND a.user_id = m.user_id
			ORDER BY m.user_username';
        if ($notify = array_merge($notify, _rowset(sql_filter($sql, $v['ticket'], $user->v('user_id')), false, 'user_email'))) {
            require_once XFS . 'core/emailer.php';
            $emailer_vars = array('USERNAME' => $user->v('user_username'), 'FULLNAME' => entity_decode(_fullname($user->v())), 'SUBJECT' => entity_decode($d['ticket_title']), 'MESSAGE' => entity_decode($v['note_text']), 'TICKET_URL' => _link($this->m(), array('x1' => 'view', 'code' => $d['ticket_code'])));
            $emailer = new emailer();
            $emailer->from($group_email . '@' . $core->v('domain'));
            $emailer->use_template('ticket_reply');
            $emailer->set_subject(sprintf('%s [#%s]: %s', _lang('REPLY'), $d['ticket_code'], $emailer_vars['SUBJECT']));
            foreach ($notify as $i => $v_email) {
                $method = !$i ? 'email_address' : 'cc';
                $emailer->{$method}($v_email);
            }
            $emailer->set_decode(true);
            $emailer->assign_vars($emailer_vars);
            $emailer->send();
            $emailer->reset();
        }
        return $this->e('~OK');
    }
Exemple #30
0
     });
});
</script>
<?php 
}
?>



		<div class="mw-ui-btn-nav"><a class="mw-ui-btn comments-group active" href="#content_id=0">
		<?php 
_e("Comments");
?>
		</a> <a class="mw-ui-btn comments-group mw-ui-btn " href="#content_id=settings">
		<?php 
_lang("Settings", "modules/comments");
?>
		</a>
         
		<?php 
/*<a href="#content_id=templates" class="comments-group mw-ui-btn ">
		<?php _e("My templates"); ?>
		</a>*/
?>
        </div>


	<div class="comments-tabs active">
		<div class="comments-tab comments-items" id="the_comments">
			<div id="comments-admin-side">
				<div class="comments-admin-header">