function _lastvisit_home() { global $user; $v = $this->__(array('username')); $v['username'] = _alias($v['username']); $sql = "SELECT user_lastvisit\n\t\t\tFROM _members\n\t\t\tWHERE username_base = '" . $this->_escape($v['username']) . "'"; if (!($lastvisit = $this->_field($sql, 'user_lastvisit'))) { $this->e('El usuario no existe.'); } $this->e($user->format_date($lastvisit)); }
public function auth_get($name, $uid = false, $global = false) { if ($uid === false) { $uid = $this->v('bio_id'); } if ($this->auth_founder($uid)) { return true; } // Get auth fields $auth_fields = $this->auth_list(); // Get all auth for uid if (!isset($this->auth[$uid])) { $this->auth[$uid] = w(); $sql = 'SELECT * FROM _bio_auth WHERE auth_bio = ?'; $auth = sql_rowset(sql_filter($sql, $uid)); foreach ($auth as $row) { if (!isset($row['auth_field'])) { continue; } $this->auth[$uid][$auth_fields[$row['auth_field']]['field_alias']] = true; } } $name = _alias($name, w('-')); $response = false; if (isset($this->auth[$uid][$name])) { $response = true; } if ($response === false) { $field_found = false; foreach ($auth_fields as $row) { if ($name === $row->field_alias) { $field_found = true; break; } } if (!$field_found) { global $core; $sql_insert = array('alias' => $name, 'name' => $name); $sql = 'INSERT INTO _bio_auth_field' . sql_build('INSERT', prefix('field', $sql_insert)); sql_query($sql); $core->cache->unload(); if ($global) { $response = true; } } } return $response; }
function _low($a, $match = false) { if (!f($a) || $match && !preg_match('#^([A-Za-z0-9\\-\\_\\ ]+)$#is', $a)) { return false; } return _alias($a); }
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('< >'), 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; }
function _low($a, $match = false) { if (empty($a) || ($match && !preg_match('#^([A-Za-z0-9\-\_\ ]+)$#is', $a))) { return false; } return _alias($a); }
function auth_get($name, $uid = false, $global = false) { if ($uid === false) { $uid = $this->v('user_id'); } if ($this->auth_founder($uid)) { return true; } // Get auth fields $auth_fields = $this->auth_list(); // Get all auth for uid if (!isset($this->auth[$uid])) { $this->auth[$uid] = w(); $sql = 'SELECT * FROM _members_auth WHERE auth_uid = ?'; $auth = _rowset(sql_filter($sql, $uid)); foreach ($auth as $row) { if (!isset($row['auth_field'])) { continue; } $this->auth[$uid][$auth_fields[$row['auth_field']]['field_alias']] = true; } } $name = _alias($name, w('-')); $response = false; if (isset($this->auth[$uid][$name])) { $response = true; } if ($response === false) { $field_found = false; foreach ($auth_fields as $row) { if ($name === $row['field_alias']) { if ($row['field_global']) { $response = true; } $field_found = true; break; } } if (!$field_found) { $sql_insert = array('alias' => $name, 'name' => $name, 'global' => (int) $global); $sql = 'INSERT INTO _members_auth_fields' . _build_array('INSERT', prefix('field', $sql_insert)); _sql($sql); global $core; $core->cache_unload(); if ($global) { $response = true; } } } return $response; }
protected function _create_home() { global $user, $core; if (_button()) { gfatal(); $v = $this->__(array('autos' => 0, 'active' => 0, 'type' => 0, 'admin' => 0, 'firstname', 'lastname', 'show', 'username', 'gender', 'email', 'password'), 'contact'); $v['contact_username'] = _alias($v['contact_username']); $sql = 'SELECT user_id FROM _members WHERE user_username = ? AND user_active = 1'; if (_fieldrow(sql_filter($sql, $v['contact_username']))) { $this->_error('#USERNAME_EXISTS'); } $internal = 0; if ($v['contact_type'] == 4) { $internal = 1; } $type = 0; if ($v['contact_admin'] && $internal) { $type = 3; } $sql_insert = array('type' => $type, 'active' => $v['contact_active'], 'internal' => $internal, 'mtype' => (int) $v['contact_type'], 'login' => $v['contact_username'], 'username' => $v['contact_username'], 'firstname' => $v['contact_firstname'], 'lastname' => $v['contact_lastname'], 'password' => _password($v['contact_password']), 'name_show' => $v['contact_show'], 'email' => f($v['contact_email']) ? $v['contact_email'] : $v['contact_username'] . '@' . $core->v('domain'), 'gender' => $v['contact_gender'], 'date' => time(), 'dateformat' => 'd M Y H:i', 'timezone' => -6); $sql = 'INSERT INTO _members' . _build_array('INSERT', prefix('user', $sql_insert)); $v['uid'] = _sql_nextid($sql); foreach (w('index ticket ticket_create ticket_view_own ticket_mini chat') as $row) { $user->auth_update($row, true, $v['uid']); } redirect(_link($this->m(), array('x1' => 'search', 'm' => $v['contact_username']))); } $mtype = $this->init_mtype(); foreach ($mtype as $row) { _style('contact_type', array('ID' => $row['type_id'], 'NAME' => $row['type_name'])); } return; }
protected function _artist_home() { $v = array_merge($v, $this->__(array('a_name', 'a_website', 'a_email', 'a_genre' => array(0), 'a_country' => 0))); $v_check = array('a_name' => 'INVALID_NAME', 'a_email' => 'INVALID_EMAIL', 'a_genre' => 'INVALID_GENRE'); foreach ($v_check as $vk => $vv) { if (!f($v[$vk])) { $this->error($vv); } } if (!$this->errors()) { $v['a_alias'] = _alias($v['a_name']); if (f($v['a_alias'])) { $sql = 'SELECT a_approved FROM _artists WHERE a_alias = ?'; if ($a_approved = _field(sql_filter($sql, $v['a_alias']), 'a_approved')) { $a_msg = $a_approved ? 'EXISTS' : 'PENDING'; $this->error('ARTIST_' . $a_msg); } } else { $this->error('INVALID_ALIAS'); } } if (!$this->errors() && !check_email($v['a_email'])) { $this->error('INVALID_EMAIL'); } if (!$this->errors()) { $sql = 'SELECT country_id FROM _countries WHERE country_id = ?'; if (!_fieldrow(sql_filter($sql, $v['a_country']))) { $this->error('INVALID_COUNTRY'); } } if (!$this->errors()) { $sql = 'SELECT type_id FROM _alias_type WHERE type_alias = ?'; $alias_type = _field(sql_filter($sql, 'artist'), 'type_id'); $sql_insert = array('name' => $v['a_name'], 'alias' => $v['a_alias'], 'approved' => 0, 'time' => time(), 'email' => strtolower($v['a_email']), 'website' => $v['a_website'], 'country' => $v['a_country'], 'biography' => '', 'views' => 0, 'music' => 0, 'video' => 0, 'news' => 0, 'posts' => 0, 'votes' => 0, 'lyrics' => 0, 'images' => 0); sql_put('_artists', prefix('a', $sql_insert)); $sql_insert = array('name' => $v['a_alias'], 'enable' => 0, 'type' => $alias_type); sql_put('_alias', prefix('alias', $sql_insert)); redirect(_link('alias', array('alias' => $v['a_alias']))); } return; }