Exemplo n.º 1
0
    function _form_home()
    {
        global $core, $user, $style;
        $tree = $this->valid_tree();
        if (!$tree['tree_form']) {
            _fatal();
        }
        if ($tree['tree_parent']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ' . (int) $tree['tree_parent'];
            $parent = $this->_fieldrow($sql);
            if ($tree['tree_level'] > 2) {
                $sql = 'SELECT *
					FROM _tree
					WHERE tree_id = ' . (int) $parent['tree_parent'];
                $subparent = $this->_fieldrow($sql);
            }
        }
        if ($tree['tree_node']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ' . (int) $tree['tree_node'];
            $node = $this->_fieldrow($sql);
        }
        //
        $sql = 'SELECT *
			FROM _form_fields
			WHERE form_tree = ' . (int) $tree['tree_id'] . '
			ORDER BY form_order';
        $form = $this->_rowset($sql, 'form_alias');
        if (!count($form)) {
            $sql = 'SELECT *
				FROM _form_fields
				WHERE form_tree = 0
				ORDER BY form_order';
            $form = $this->_rowset($sql, 'form_alias');
        }
        $form['ctkey'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'ctkey', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad');
        if (_button()) {
            $va = array();
            foreach ($form as $row) {
                $va[] = $row['form_alias'];
            }
            $v = $this->__($va);
            foreach ($form as $row) {
                if (empty($v[$row['form_alias']])) {
                    if ($row['form_required']) {
                        $this->error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false);
                    }
                    continue;
                }
                if (!empty($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'] == 'ctkey') {
                        $v[$row['form_alias']] = '';
                    }
                }
            }
            if (!$this->errors()) {
                include XFS . 'core/xcf.php';
                $xcf = new captcha();
                if ($xcf->check($v['ctkey']) === false) {
                    $v['ctkey'] = '';
                    $this->error('E_COMMENT_INVALID_CAPTCHA');
                }
                unset($xcf);
            }
            if (!$this->errors()) {
                include XFS . 'core/emailer.php';
                $emailer = new emailer();
                $v['subject'] = preg_replace('#\\&([A-Za-z]+){1}(.*?)\\;#e', "substr('\\1', 0, 1)", $v['subject']);
                $emailer->from($v['email']);
                $emailer->set_subject($v['subject']);
                $emailer->use_template('contact_email', $core->v('default_lang'));
                foreach (explode(';', $tree['tree_form_email']) as $i => $address) {
                    $row_f = !$i ? 'email_address' : 'cc';
                    $emailer->{$row_f}($address);
                }
                $emailer->cc($core->v('default_email'));
                unset($v['ctkey']);
                $html = array();
                foreach ($form as $row) {
                    if (empty($v[$row['form_alias']])) {
                        continue;
                    }
                    if ($row['form_alias'] == 'message') {
                        $v['message'] = str_replace("\r\n", '<br />', $v['message']);
                    }
                    $html[] = '<strong>' . $row['form_legend'] . ':</strong><br />' . $v[$row['form_alias']];
                }
                $emailer->assign_vars(array('HTML_FIELDS' => implode('<br /><br />', $html), 'FROM_USERNAME' => $v['nombre'], 'FORM_ARTICLE' => $tree['tree_subject']));
                $emailer->send();
                $emailer->reset();
                //
                $style->assign_block_vars('sent', array('THANKS' => _lang('CONTACT_THANKS')));
            }
        }
        if (!_button() || $this->errors()) {
            if ($this->errors()) {
                $style->assign_block_vars('error', array('MESSAGE' => error_list($this->error)));
            }
            $ff = 'form_';
            $fff = 'alias|type';
            $style->assign_block_vars('form', array());
            foreach ($form as $row) {
                $style->assign_block_vars('form.row', array('ALIAS' => $row[$ff . 'alias'], 'REQUIRED' => $row[$ff . 'required'], 'LEGEND' => $row[$ff . 'legend'], 'TYPE' => $row[$ff . 'type'], 'ERROR' => isset($error[$row[$ff . 'alias']]), 'VALUE' => isset($v[$row[$ff . 'alias']]) ? $v[$row[$ff . 'alias']] : ''));
                foreach ($row as $row_k => $row_v) {
                    if (preg_match('#^' . $ff . '(' . $fff . ')$#is', $row_k)) {
                        if ($row_k == 'form_alias') {
                            $row_k = 'name';
                        }
                        $style->assign_block_vars('form.row.attrib', array('ATTRIB' => str_replace($ff, '', $row_k), 'VALUE' => $row_v));
                    }
                }
            }
        }
        //
        $s_css_page = '';
        if (@file_exists('./style/css/_tree_' . $this->alias_id($tree) . '.css')) {
            $s_css_page = $this->alias_id($tree) . '/';
        } elseif ($this->css_parent($tree)) {
            if (empty($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_numeric($tree['tree_css_var'])) {
                        $sql = 'SELECT *
							FROM _tree
							WHERE tree_id = ' . (int) $tree['tree_css_var'];
                        if ($css_var_row = $this->_fieldrow($sql)) {
                            $ary_css_var = $css_var_row;
                        }
                    }
                    break;
            }
            if ($ary_css_var !== false) {
                $s_css_page = $this->alias_id($ary_css_var) . '/';
            }
        }
        //
        $tv = array('ADI' => $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']);
        $this->as_vars($tv);
        //
        if ($tree['tree_alias'] != 'home') {
            if ($node['tree_id'] != $parent['tree_id']) {
                $this->navigation($node['tree_subject'], $this->alias_id($node));
            }
            if ($tree['tree_level'] > 2) {
                if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) {
                    $this->navigation('...');
                }
                $this->navigation($subparent['tree_subject'], $this->alias_id($subparent));
            }
            if ($parent['tree_id']) {
                $this->navigation($parent['tree_subject'], $this->alias_id($parent));
            }
            $this->navigation($tree['tree_subject'], $this->alias_id($tree));
        }
        //$tree['tree_subject'] = strip_tags($tree['tree_subject']);
        //
        $this->template = 'default.form';
        if (!empty($tree['tree_template']) && @file_exists('./style/pages/form.' . $tree['tree_template'] . '.htm')) {
            $this->template = 'pages/form.' . $tree['tree_template'];
        }
        return;
    }
Exemplo n.º 2
0
		AND user_birthday LIKE '%??'
		AND user_birthday_last < ?
	ORDER BY username
	LIMIT ??";
$result = sql_rowset(sql_filter($sql, USER_INACTIVE, date('md'), date('Y'), $max_email));

$done = array();
$usernames = array();

foreach ($result as $row) {
	$emailer->from('notify');
	$emailer->use_template('user_birthday');
	$emailer->email_address($row['user_email']);
	if (!empty($row['user_public_email']) && $row['user_email'] != $row['user_public_email'])
	{
		$emailer->cc($row['user_public_email']);
	}

	$emailer->assign_vars(array(
		'USERNAME' => $row['username'])
	);
	$emailer->send();
	$emailer->reset();

	$done[] = $row['user_id'];
	$usernames[] = $row['username'];
}

if (count($done))
{
	$sql = 'UPDATE _members SET user_birthday_last = ?