public function home() { /* $sql = 'SELECT * FROM _store WHERE store_field = 4 ORDER BY store_value'; $countries = _rowset($sql); foreach ($countries as $row) { $sv = ucwords(_rm_acute($row['store_value'])); $sql = 'UPDATE _store SET store_value = ? WHERE store_id = ?'; _sql(sql_filter($sql, $sv, $row['store_id'])); } */ $sql = 'SELECT DISTINCT store_value FROM _store WHERE store_field = 4 ORDER BY store_value'; $countries = _rowset($sql, 'store_value'); _pre($countries, true); $this->e(''); return; }
protected function _ticket_members() { $v = $this->__(w('change_user')); $sql = "SELECT user_id, username\n\t\t\tFROM _members\n\t\t\tWHERE user_firstname LIKE '??%'\n\t\t\tORDER BY user_firstname"; $list = _rowset(sql_filter($sql, $v['change_user'])); $members = w(); foreach ($list as $row) { $members[$row['user_id']] = _fullname($row); } return $this->_dom_ul($members); }
public function home() { global $core; $v = $this->__(array('a', 'p' => 0)); if (f($v['a'])) { $sql = 'SELECT area_id FROM _reference_area WHERE area_alias = ?'; if (!_field(sql_filter($sql, $v['a']), 'area_id', 0)) { _fatal(); } $sql = 'SELECT COUNT(r.ref_id) AS total FROM _reference r, _reference_area a WHERE a.area_alias = ? AND r.ref_area = a.area_id ORDER BY r.ref_time DESC'; $ref_total = _field(sql_filter($sql, $v['a']), 'total', 0); $sql = 'SELECT * FROM _reference r, _reference_area a WHERE a.area_alias = ? AND r.ref_area = a.area_id ORDER BY r.ref_time DESC LIMIT ??, ??'; $ref = _rowset(sql_filter($sql, $v['a'], $v['p'], $core->v('ref_pages'))); } else { $sql = 'SELECT COUNT(ref_id) AS total FROM _reference ORDER BY ref_time DESC'; $ref_total = _field($sql, 'total', 0); $sql = 'SELECT * FROM _reference r, _reference_area a WHERE r.ref_area = a.area_id ORDER BY r.ref_time DESC LIMIT ??, ??'; $ref = _rowset(sql_filter($sql, $v['p'], $core->v('ref_pages'))); } if ($v['p'] && $ref_total) { redirect(_link()); } else { _style('noref'); } foreach ($ref as $i => $row) { if (!$i) { _style('ref'); } if ($this->has_plugin($row['ref_content'])) { $this->parse_plugin($row); continue; } _style('ref.row', _vs(array('id' => $row['ref_id'], 'link' => _link($row['ref_alias']), 'subject' => $row['ref_subject'], 'content' => _message($row['ref_content']), 'time' => _format_date($row['ref_time'])), 'ref')); } return; }
function _help_home() { global $bio; $ha = $bio->v('auth_comments'); if ($ha) { $ha_add = $bio->v('auth_help_create'); $ha_edit = $bio->v('auth_help_modufy'); $ha_delete = $bio->v('auth_help_remove'); } $sql = 'SELECT c.*, m.* FROM _help_cat c, _help_modules m WHERE c.help_module = m.module_id ORDER BY c.help_order'; $cat = _rowset($sql, 'help_id'); $sql = 'SELECT * FROM _help_faq'; $faq = _rowset($sql, 'faq_id'); // // Loop // foreach ($cat as $help_id => $cdata) { _style('cat', array('HELP_ES' => $cdata['help_es'], 'HELP_EN' => $cdata['help_en'], 'HELP_EDIT' => _link_control('comments', array('mode' => $this->mode)), 'HELP_UP' => _link_control('comments', array('mode' => $this->mode)), 'HELP_DOWN' => _link_control('comments', array('mode' => $this->mode)))); if ($ha_edit) { _style('cat.edit', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'edit', 'sub' => 'cat', 'id' => $help_id)), 'UP' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'edit', 'sub' => 'cat', 'id' => $help_id, 'order' => '_15')), 'DOWN' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'edit', 'sub' => 'cat', 'id' => $help_id, 'order' => '15')))); } if ($ha_delete) { _style('cat.delete', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'delete', 'sub' => 'cat', 'id' => $help_id)))); } foreach ($faq as $faq_id => $fdata) { if ($help_id != $fdata['help_id']) { continue; } _style('cat.faq', array('QUESTION_ES' => $fdata['faq_question_es'], 'ANSWER_ES' => _message($fdata['faq_answer_es']))); if ($ha_edit) { _style('cat.faq.edit', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'edit', 'sub' => 'faq', 'id' => $fdata['faq_id'])))); } if ($ha_delete) { _style('cat.faq.delete', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'delete', 'sub' => 'faq', 'id' => $fdata['faq_id'])))); } } } if ($ha_add) { _style('add', array('URL' => _link_control('comments', array('mode' => $this->mode, 'manage' => 'add')))); } $this->nav(); return; }
public function home() { $cols = w('Email Nickname Cumpleaños País'); $sql = 'SELECT user_email, user_username, user_birthday, country_name FROM _members m, _countries c WHERE m.user_type = ? AND m.user_country = c.country_id ORDER BY m.user_username'; $members = _rowset(sql_filter($sql, 1)); foreach ($members as $i => $rowm) { if (!$i) { _style('table'); foreach ($cols as $j => $field) { if (!$j) { _style('table.head', array('TITLE' => '#')); } _style('table.head', array('TITLE' => $field)); } } _style('table.row'); $j = 0; foreach ($rowm as $f => $row) { if (!$j) { _style('table.row.col', array('VALUE' => $i + 1)); } switch ($f) { case 'user_birthday': $row_year = substr($row, 0, 4); $row_month = substr($row, 4, 2); $row_day = substr($row, 6, 2); $row = _format_date(_timestamp($row_month, $row_day, $row_year), 'd F Y'); break; } _style('table.row.col', array('VALUE' => $row)); $j++; } } return; }
public function home() { $sql = 'SELECT * FROM _store s, _store_fields f WHERE s.store_field = f.field_id ORDER BY store_field'; $store = _rowset($sql, 'store_assoc', false, true); $a_country = array('Alemania' => 82, 'Argentina' => 10, 'Bolivia' => 26, 'Chile' => 43, 'Colombia' => 47, 'Ecuador' => 63, 'El Salvador' => 65, 'Espana' => 197, 'Francia' => 74, 'Greece' => 85, 'Guatemala' => 90, 'Honduras' => 97, 'Italia' => 107, 'Mexico' => 140, 'Paraguay' => 168, 'Peru' => 169, 'Uruguay' => 227, 'Venezuela' => 230); foreach ($store as $i => $row) { $nickname = ''; $address = ''; $birthday = ''; $country = ''; foreach ($row as $field) { switch ($field['field_alias']) { case 'nickname': $nickname = $field['store_value']; break; case 'address': $address = $field['store_value']; break; case 'birthday': $temp = explode('/', $field['store_value']); $birthday = $temp[2] . '' . $temp[1] . '' . $temp[0]; break; case 'country': $country = $a_country[$field['store_value']]; break; } } $sql_insert = array('type' => 1, 'active' => 0, 'username' => $nickname, 'password' => '', 'registration' => time(), 'lastvisit' => 0, 'lastpage' => '', 'country' => $country, 'email' => $address, 'birthday' => $birthday, 'birthday_last' => 0, 'gender' => 0, 'date' => 0, 'dateformat' => 'd M Y H:i', 'timezone' => -6, 'dst' => 0, 'login_tries' => 0); $sql = 'INSERT INTO _members' . _build_array('INSERT', prefix('user', $sql_insert)); _sql($sql); //_pre($sql); } $this->e('Done.'); return; }
function home() { $sql = 'SELECT * FROM _members WHERE user_type = ? AND user_birthday LIKE ? AND user_birthday_last < ? ORDER BY user_username LIMIT ??'; $birthday = _rowset(sql_filter($sql, 1, '%' . date('md'), date('Y'), 10)); if (!$birthday) { $this->e('None.'); } $process = w(); foreach ($birthday as $i => $row) { if (!$i) { @set_time_limit(0); require XFS . 'core/emailer.php'; $emailer = new emailer(); } $emailer->format('plain'); $emailer->from('TWC Kaulitz <*****@*****.**>'); $emailer->use_template('user_birthday'); $emailer->email_address($row['user_email']); $emailer->assign_vars(array('USERNAME' => $row['user_username'])); $emailer->send(); $emailer->reset(); $process[$row['user_id']] = $row['user_username']; } if (count($process)) { $sql = 'UPDATE _members SET user_birthday_last = ? WHERE user_id IN (??)'; _sql(sql_filter($sql, date('Y'), _implode(',', array_keys($process)))); } return $this->e('Done @ ' . implode(',', array_values($process))); }
public function home() { global $bio, $core; $sql = 'SELECT show_alias, show_name FROM _radio_shows WHERE show_active = ? ORDER BY show_name'; $shows = _rowset(sql_filter($sql, 1)); // $sql = 'SELECT d.dj_show, b.bio_alias, b.bio_name FROM _radio_dj d, _bio b WHERE d.dj_bio = b.bio_id ORDER BY m.bio_name'; $dj = _rowset($sql, 'dj_show', false, true); $sql = 'SELECT archive_id, archive_show, archive_alias, archive_name FROM _radio_archives ORDER BY article_order, archive_time'; $archive = _rowset($sql); $sql = 'SELECT * FROM _radio_articles ORDER BY announce_show, announce_time'; $announce = _rowset($sql, 'announce_show', false, true); return; }
protected function _view_home() { global $core, $bio; $v = $this->__(array('alias', 't' => 0, 'p' => 0)); if (!f($v['alias'])) { _fatal(); } $v['field'] = !is_numb($v['alias']) ? 'alias' : 'id'; $sql = 'SELECT * FROM _events WHERE event_?? = ?'; if (!($event = _fieldrow(sql_filter($sql, $v['field'], $v['alias'])))) { _fatal(); } if ($v['field'] == 'id' && f($event['event_alias'])) { redirect(_link($this->m(), $event['event_alias']) . _linkp(array('t' => $v['t'], 'p' => $v['p']), true)); } // Get images $sql = 'SELECT * FROM _events_images WHERE image_event = ? ORDER BY image ASC LIMIT ??, ??'; $event_images = _rowset(sql_filter($sql, $event['event_id'], $v['t'], $core->v('thumbs_per_page'))); foreach ($event_images as $i => $row) { if (!$i) { _style('thumbnails', _pagination(_link($this->m(), $event['event_alias']), 't:%d', $event['event_images'], $core->v('thumbs_per_page'), $v['t'])); } _style('thumbnails.row', array('U_THUMBNAIL' => _lib(w(LIB_EVENT . ' thumbnail ' . $event['event_id'], $row['image'], 'jpg')), 'U_IMAGE' => _lib(w(LIB_EVENT . ' gallery ' . $event['event_id'], $row['image'], 'jpg')), 'V_FOOTER' => $row['image_footer'])); } if (is_ghost()) { return; } // Statistics if (!$v['t'] && !$bio->v('auth_founder')) { $this->_stats_store(); } $is_future = $row['event_end'] > time() ? true : false; if (!$is_future) { // Star for favourites if (!($star_type = $core->cache_load('star_type'))) { $sql = 'SELECT type_id, type_name FROM _events_star_type ORDER BY type_order'; $types = $core->cache_store('star_type', _rowset($sql, 'type_id', 'type_name')); } $i = 0; foreach ($types as $type_id => $type_name) { if (!$i) { _style('star_type'); } _style('star_type.row', array('TYPE_ID' => $type_id, 'TYPE_NAME' => $type_name)); $i++; } } else { $sql = 'SELECT * FROM _events_reviews r, _bio b WHERE r.review_event = ? AND r.review_uid = b.bio_id ORDER BY r.review_avg LIMIT 0, 5'; $reviews = _rowset(sql_filter($sql, $event['event_id']), 'review_id'); $sql = 'SELECT * FROM _events_reviews_rate r, _events_reviews_fields f WHERE r.rate_review IN (??) AND r.rate_field = f.field_id ORDER BY f.field_order'; $reviews_rate = _rowset(sql_filter($sql, _implode(',', array_keys($reviews))), 'rate_review', false, true); $i = 0; foreach ($reviews as $row) { if (!$i) { _style('reviews'); } _style('reviews.row', array('REVIEW_CONTENT' => $row['review_content'], 'REVIEW_' => $row['review_'])); if (isset($reviews_rate[$row['review_id']])) { foreach ($reviews_rate[$row['review_id']] as $j => $rate) { if (!$j) { _style('reviews.row.rate'); } _style('reviews.row.rate.field', array('FIELD' => $rate['field_name'], 'RATE' => $rate['rate_value'])); } } $i++; } } // Who attend $sql = 'SELECT at.type_id, at.type_name_next, at.type_name_prev, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up FROM _events_attend a, _events_attend_type at, _bio b WHERE a.attend_event = ? AND a.attend_type = at.type_id AND a.attend_uid = b.bio_id ORDER BY a.attend_time'; $attend = _rowset(sql_filter($sql, $event['event_id']), 'type_id', false, true); $i = 0; foreach ($attend as $type_name => $rows) { if (!$i) { _style('attend'); } $type_name = $is_future ? 'next' : 'prev'; _style('attend.type', array('TYPE_NAME' => $rows[0]['type_name_' . $type_name])); foreach ($rows as $row) { _style('attend.type.row', array('BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row))); } $i++; } // Messages $ref = _link('events', $event['event_alias']); if ($event['event_publish']) { if ($event['event_comments']) { $sql = 'SELECT c.comment_id, c.comment_time, c.comment_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up FROM _events_comments c, _bio b WHERE c.comment_event = ? AND c.comment_active = ? AND c.comment_bio = b.bio_id ORDER BY c.comment_time DESC LIMIT ??, ??'; $comments = _rowset(sql_filter($sql, $event['event_id'], 1, $v['p'], $core->v('events_comments'))); foreach ($comments as $i => $row) { if (!$i) { _style('comment_area', _pagination(_link($this->m(), array($event['event_alias'], $v['t'], 's%d')), $topic_data['topic_replies'] + 1, $core->v('posts_per_page'), $start)); } _style('comment_area.row', array('BIO_ALIAS' => _link_bio($row['bio_alias']), 'BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row), 'COMMENT_ID' => $row['comment_id'], 'COMMENT_TIME' => _format_date($row['comment_time']), 'COMMENT_TEXT' => _message($row['comment_text']))); } } _style('comment_publish', array('U_PUBLISH' => _link())); } // if ($event['event_posts']) { $reply = array('ref' => $ref, 'start' => $v['p'], 'start_f' => 's', 'rows' => $event['event_posts'], 'rows_page' => $core->v('s_posts'), 'block' => 'posts', 'sql' => 'SELECT p.post_id, p.post_time, p.post_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up, b.bio_sig FROM _events_posts p, _bio b WHERE p.post_event = ? AND p.post_active = 1 AND p.post_uid = b.bio_id ORDER BY p.post_time DESC LIMIT {START}, {ROWS_PAGE}'); $reply['sql'] = sql_filter($reply['sql'], $event['event_id']); $this->_replies($reply); } v_style(_vs(array('SUBJECT' => $event['event_subject'], 'IMAGES' => $event['event_images'], 'START' => _format_date($event['event_start'], 'd F Y'), 'END' => _format_date($event['event_end'], 'd F Y'), 'COMMENTS' => $event['event_posts']), 'event')); return; }
function _countries($s = false) { global $core; if (!($countries = $core->cache->load('countries'))) { $sql = 'SELECT * FROM _countries ORDER BY country_id'; $countries = $core->cache->store(_rowset($sql, 'country_id')); } if ($s !== false && isset($countries[$s])) { $countries = $countries[$s]; } return $countries; }
function _rowset_style($sql, $style, $prefix = '', $comp_orig = false, $comp_dest = false) { $a = _rowset($sql); _rowset_foreach($a, $style, $prefix, $comp_orig, $comp_dest); return $a; }
protected function _bios_home() { $sql = 'SELECT field_alias, field_id FROM _bio_fields ORDER BY field_alias'; $store_fields = _rowset($sql, 'field_alias', 'field_id'); $current_fields = array('public_email' => 'email_0', 'fav_artists' => 'fartists', 'fav_genres' => 'fgenres', 'icq' => 'icq', 'interests' => 'interests', 'lastfm' => 'lastfm', 'location' => 'location', 'occ' => 'occ', 'os' => 'os', 'website' => 'website', 'msnm' => 'wlive'); $sql = 'SELECT * FROM _members WHERE user_id <> 1 ORDER BY user_id'; $members = _rowset($sql); foreach ($members as $row) { $user_firstname = ''; $user_lastname = ''; switch ($row['user_id']) { case 2: $user_firstname = 'Guillermo'; $user_lastname = 'Azurdia'; break; case 3: $user_firstname = 'Gerardo'; $user_lastname = 'Medina'; break; } $sql_insert = array('bio_type' => 2, 'bio_level' => $row['user_type'] ? $row['user_type'] : 0, 'bio_active' => $row['user_active'] ? $row['user_active'] : 0, 'bio_alias' => $row['username_base'] ? $row['username_base'] : '', 'bio_name' => $row['username'] ? $row['username'] : '', 'bio_first' => $user_firstname, 'bio_last' => $user_lastname, 'bio_key' => $row['user_password'] ? $row['user_password'] : '', 'bio_address' => $row['user_email'] ? strtolower($row['user_email']) : '', 'bio_gender' => $row['user_gender'] ? $row['user_gender'] : '', 'bio_birth' => $row['user_birthday'] ? $row['user_birthday'] : 0, 'bio_birthlast' => $row['user_birthday_last'] ? $row['user_birthday_last'] : 0, 'bio_regip' => $row['user_regip'] ? $row['user_regip'] : '', 'bio_regdate' => $row['user_regdate'] ? $row['user_regdate'] : 0, 'bio_lastvisit' => $row['user_lastvisit'] ? $row['user_lastvisit'] : 0, 'bio_session_time' => $row['user_session_time'] ? $row['user_session_time'] : 0, 'bio_lastpage' => '', 'bio_timezone' => $row['user_timezone'] ? $row['user_timezone'] : 0.0, 'bio_dst' => $row['user_dst'] ? $row['user_dst'] : 0, 'bio_dateformat' => $row['user_dateformat'] ? $row['user_dateformat'] : '', 'bio_lang' => $row['user_lang'] ? $row['user_lang'] : 'es', 'bio_country' => !$row['user_country'] ? 90 : $row['user_country'], 'bio_avatar' => $row['user_avatar'] ? $row['user_avatar'] : '', 'bio_avatar_up' => $row['user_avatar'] ? substr(md5(unique_id()), 0, 10) : '', 'bio_actkey' => '', 'bio_recovery' => '', 'bio_fails' => 0); $bio_id = sql_put('_bio', $sql_insert); foreach ($current_fields as $current_field => $new_field) { if (isset($row['user_' . $current_field]) && f($row['user_' . $current_field])) { $sql_insert = array('bio' => $bio_id, 'field' => $store_fields[$new_field], 'value' => $row['user_' . $current_field]); sql_put('_bio_store', prefix('store', $sql_insert)); } } if (isset($row['user_send_mass']) && $row['user_send_mass']) { $sql_insert = array('bio' => $bio_id, 'receive' => $row['user_send_mass']); sql_put('_bio_newsletter', prefix('newsletter', $sql_insert)); } } /* $sql = 'SELECT * FROM _members_friends ORDER BY user_id, buddy_id'; $friends = _rowset($sql); foreach ($friends as $row) { $sql_insert = array( 'assoc' => $row['buddy_id'], 'bio' => $row['user_id'], 'active' => 1, 'time' => $row['friend_time'], 'message' => '' ); sql_put('_bio_friends', prefix('friend', $sql_insert)); } */ return $this->e('~OK'); }
protected function _account_home() { global $bio, $core; if (_button()) { $sql = 'SELECT * FROM _bio_fields ORDER BY field_alias'; $fields = _rowset($sql, 'field_alias'); $v = $this->__(array_merge(w('address password password_verify gender' . _implode(' ', array_subkey($fields, 'field_alias'))), array('timezone' => 0, 'birthday' => array(0)))); $field_error = array('address' => 'NO_ADDRESS', 'password' => 'NO_PASSWORD', 'password_verify' => 'NO_PASSWORD_VERIFY'); foreach ($v as $k => $vv) { if (!f($vv)) { $this->error('#'); } } if (is_ghost() && $this->errors()) { $this->e('!'); } redirect(_link('my', 'page')); } return; /* if (_button()) { if (!$this->errrors()) { $avatar_changed = (isset($this->data['old_avatar'])) ? true : false; // Update DB if something was changed if (sizeof($sql_update)) { if (isset($sql_update['bio_avatar'])) { if (f($bio->v('bio_avatar'))) { @unlink('..' . $core->v('avatar_path') . $bio->v('bio_avatar')); } @rename($this->data['old_avatar'], '..' . $core->v('avatar_path') . $sql_update['bio_avatar']); } } // Redirect to userpage } } // IF submit // Selects $this->ss_build('dateformat', 'timezone', 'gender', 'birthday', 'topic_order', 'mark_items'); // Vars $sv = array( 'AVATAR_MAXSIZE' => $core->v('avatar_filesize'), 'L_AVATAR_EXPLAIN' => sprintf(_lang('AVATAR_EXPLAIN'), $core->v('avatar_max_width'), $core->v('avatar_max_height')) ) + $this->fields_fvars(); */ }
protected final function _replies($f) { global $bio; $rf_k = $rf_v = w(); foreach ($f as $k => $v) { $rf_k[] = '{' . strtoupper($k) . '}'; } $rf_v = array_values($f); $f['sql'] = str_replace($rf_k, $rf_v, $f['sql']); if (!($rows = _rowset($f['sql']))) { return; } // TODO: Control Panel. Modify & remove comments $bio = w(); foreach ($rows as $i => $row) { if (!$i) { _style($f['block'], _vs(_pagination($f['ref'], $f['start_f'] . ':%d', $f['rows'], $f['rows_page'], $f['start']))); } $uid = $row['bio_id']; $row['is_member'] = $uid != 1 ? 1 : 0; if (!isset($bio[$uid]) || !$row['is_member']) { $bio[$uid] = $this->_profile($row); } $s_row = array('V_MEMBER' => $row['is_member'], 'V_TIME' => _format_date($row['post_time']), 'V_MESSAGE' => _message($row['post_text'])); _style($f['block'] . '.row', array_merge($s_row, _vs($bio[$uid], 'v'))); } return; }
public function home() { global $core, $bio; $page = 15; $today = _htimestamp('md'); _pre($bio->v('is_bio'), true); _style('status_post'); // Friends birthday if ($bio->v('auth_member')) { $sql = "SELECT bio_id, bio_alias, bio_name\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_id IN (\r\n\t\t\t\t\t\tSELECT fan_of\r\n\t\t\t\t\t\tFROM _bio_fans\r\n\t\t\t\t\t\tWHERE fan_assoc = ?\r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND bio_active = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name"; $birthday = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, $today)); } else { $sql = "SELECT bio_id, bio_alias, bio_name, bio_avatar, bio_avatar_up\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_level = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name"; $birthday = _rowset(sql_filter($sql, 1, $today)); } foreach ($birthday as $i => $row) { if (!$i) { _style('birthday'); } _style('birthday.row', array('A' => _a($row), 'NAME' => $row['bio_name'], 'AVATAR' => _avatar($row))); } // Board topics if ($bio->v('auth_member')) { $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class FROM _board_topics t INNER JOIN _board_forums f ON f.forum_id = t.topic_forum LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id RIGHT JOIN _board_disallow d ON t.topic_id = d.disallow_topic AND d.disallow_bio = ? WHERE t.topic_show = ? ORDER BY t.topic_shine DESC, t.topic_time DESC LIMIT ??'; $topics = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, 10)); } else { $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class FROM _board_topics t INNER JOIN _board_forums f ON f.forum_id = t.topic_forum LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id WHERE t.topic_show = ? ORDER BY t.topic_shine DESC, t.topic_time DESC LIMIT ??'; $topics = _rowset(sql_filter($sql, 1, 10)); } foreach ($topics as $i => $row) { if (!$i) { _style('board_topics'); } _style('board_topics.row', _vs(array('ID' => $row['topic_id'], 'TITLE' => $row['topic_title'], 'CLASS' => $row['highlight_class']), 'TOPIC')); } if ($bio->v('auth_member')) { // Messages $sql = 'SELECT * FROM _bio_messages INNER JOIN _bio ON message_from = bio_id INNER JOIN _bio_messages_type ON message_type = type_id WHERE message_to = ? AND message_active = ? ORDER BY message_time DESC'; $messages = _rowset(sql_filter($sql, $bio->v('bio_id'), 1)); foreach ($messages as $i => $row) { if (!$i) { _style('messages'); } _style('messages.row', array('U_MESSAGE' => _link(), '' => '')); } // Friend requests $sql = 'SELECT b.bio_alias, b.bio_name FROM _bio_friends INNER JOIN _bio ON friend_assoc = bio_id WHERE friend_bio = ? AND friend_pending = ? ORDER BY friend_time DESC'; $requests = _rowset(sql_filter($sql, $bio->v('bio_id'), 1)); foreach ($requests as $i => $row) { if (!$i) { _style('friend_request'); } _style('friend_request.row', array('U_APPROVE' => _link('home', array('x1' => 'friend', 'x2' => 'approve', 'a' => $row['bio_alias'])), 'U_DENY' => _link('home', array('x1' => 'friend', 'x2' => 'deny', 'a' => $row['bio_alias'])), 'A' => _a($row), 'BIO_NAME' => $row['bio_name'])); } } // Banners $this->announce('home'); return; }
protected function _press_home() { global $bio; $sql = 'SELECT * FROM _newsletter WHERE newsletter_active = 1 LIMIT 1'; if (!($newsletter = _fieldrow($sql))) { $this->warning->set('no_newsletter'); } set_time_limit(0); if (!$newsletter->newsletter_start) { $sql = 'UPDATE _newsletter SET newsletter_start = ? WHERE newsletter_id = ?'; sql_query(sql_filter($sql, time(), $newsletter->newsletter_id)); } $sql = 'SELECT bio_id, bio_alias, bio_name, bio_address, bio_lastvisit FROM _bio b ?? RIGHT JOIN _bio_newsletter bn ON b.bio_id = bn.newsletter_bio AND bn.newsletter_receive = ? WHERE b.bio_lastvisit >= ? AND b.bio_status <> ? ORDER BY b.bio_name LIMIT ??, ??'; $sql_country = ''; if (!empty($newsletter->newsletter_country)) { $sql_country = sql_filter(' LEFT JOIN _countries ON bio_country = country_id AND country_id IN (??)', implode(', ', w($newsletter->newsletter_country))); } $members = _rowset(sql_filter($sql, $sql_country, 1, $newsletter['newsletter_lastvisit'], 2, $newsletter->newsletter_last, $core->v('newsletter_process'))); $i = 0; foreach ($members as $row) { if (!is_email($row['user_email'])) { continue; } $email = array('USERNAME' => $row->username, 'MESSAGE' => entity_decode($email->email_message)); $core->email->init('press', 'mass:plain', $email); $core->email->subject(entity_decode($email['email_subject'])); if (!empty($row['user_public_email']) && $row['user_email'] != $row['user_public_email'] && is_email($row['user_public_email'])) { $core->email->cc($row->bio_address_public); } $core->email->send($row->user_email); $sql_history = array('history_newsletter' => $newsletter->newsletter_id, 'history_bio' => $row->bio_id, 'history_time' => time()); sql_put('_newsletter_history', $sql_history); sleep(2); $i++; } if ($i) { $email['email_last'] += $i; $sql = 'UPDATE _newsletter SET newsletter_last = ? WHERE newsletter_id = ?'; sql_query(sql_filter($sql, $newsletter->newsletter_last, $newsletter->newsletter_id)); } else { $sql = 'UPDATE _newsletter SET newsletter_active = ?, newsletter_end = ? WHERE newsletter_id = ?'; sql_query(sql_filter($sql, 0, time(), $newsletter->newsletter_id)); $this->warning->set('finished: ' . $newsletter->newsletter_id); } return $this->warning->set('completed: ' . $i); }
public final function _install() { global $core; // TODO: Improve module installation! // Pre run check if (!($modules = $core->cache_load('modules'))) { $sql = 'SELECT * FROM _modules ORDER BY module_name'; $modules = $core->cache_store(_rowset($sql)); } $run_install = true; foreach ($modules as $row) { if ($row['module_alias'] === $this->m()) { $run_install = false; } } // Run module install if ($run_install) { $proc = $this->install(); // Post install $sql_insert = array('alias' => $this->m(), 'name' => $proc['NAME'], 'author' => $proc['AUTHOR'], 'link' => $proc['LINK']); $sql = 'INSERT INTO _modules' . _build_array('INSERT', prefix('module', $sql_insert)); _sql($sql); } return; }
function _rowset_style($sql, $style, $prefix = '') { $a = _rowset($sql); _rowset_foreach($a, $style, $prefix); return $a; }
function core() { $sql = 'SELECT * FROM _config'; $this->config = _rowset($sql, 'config_name', 'config_value'); if ($this->v('site_disabled')) { exit('SITE DISABLED'); } $address = $this->v('address'); $host_addr = array_key(explode('/', array_key(explode('://', $address), 1)), 0); if ($host_addr != get_host()) { $allow_hosts = get_file('./base/domain_alias'); foreach ($allow_hosts as $row) { if (substr($row, 0, 1) == '#') { continue; } $remote = strpos($row, '*') === false; $row = !$remote ? str_replace('*', '', $row) : $row; $row = str_replace('www.', '', $row); if ($row == get_host()) { $sub = str_replace($row, '', get_host()); $sub = f($sub) ? $sub . '.' : ($remote ? 'www.' : ''); $address = str_replace($host_addr, $sub . $row, $address); $this->v('address', $address, true); break; } } } if (strpos($address, 'www.') !== false && strpos(get_host(), 'www.') === false && strpos($address, get_host())) { $a = $this->v('address') . str_replace(str_replace('www.', '', $address), '', _page()); redirect($a, false); } $this->cache_dir = XFS . 'core/cache/'; if (is_remote() && @file_exists($this->cache_dir) && @is_writable($this->cache_dir) && @is_readable($this->cache_dir)) { $this->cache_f = true; } return; }
public function home() { global $user; $v = $this->__(array('faddr', 'nickname', 'address', 'birthday' => array('' => 0), 'country' => 0)); foreach (w('year month day') as $name) { $v['birthday'][$name] = isset($v['birthday'][$name]) ? $v['birthday'][$name] : ''; } if (f($v['faddr'])) { $v['address'] = $v['faddr']; } if (_button()) { if (!f($v['address']) || !f($v['nickname'])) { $this->error('COMPLETE_FIELDS'); } if (f($v['address'])) { $sql = 'SELECT user_id FROM _members WHERE user_email = ?'; if (_field(sql_filter($sql, $v['address']), 'user_id', 0)) { $this->error('EMAIL_EXISTS'); } if (!preg_match('/^[a-z0-9&\'\\.\\-_\\+]+@[a-z0-9\\-]+\\.([a-z0-9\\-]+\\.)*?[a-z]+$/is', $v['address'])) { $this->error('EMAIL_BAD'); } } $sql = 'SELECT country_id FROM _countries WHERE country_id = ?'; if (!_field(sql_filter($sql, $v['country']), 'country_id', 0)) { $this->error('NO_COUNTRY'); } if (!$this->errors()) { $v['birthday'] = _zero($v['birthday']['year']) . _zero($v['birthday']['month']) . _zero($v['birthday']['day']); $sql_insert = array('type' => 1, 'active' => 0, 'username' => $v['nickname'], 'password' => '', 'registration' => time(), 'lastvisit' => '', 'lastpage' => '', 'country' => $v['country'], 'email' => $v['address'], 'birthday' => $v['birthday'], 'gender' => 0, 'dateformat' => 'd M Y H:i', 'timezone' => 0, 'dst' => 0); $sql = 'INSERT INTO _members' . _build_array('INSERT', prefix('user', $sql_insert)); _sql($sql); require XFS . 'core/emailer.php'; $emailer = new emailer(); $emailer->format('plain'); $emailer->from('TWC Kaulitz <*****@*****.**>'); $emailer->use_template('welcome'); $emailer->email_address($v['address']); $emailer->assign_vars(array('USERNAME' => $v['nickname'])); $emailer->send(); $emailer->reset(); // redirect('http://www.twckaulitz.com/', false); } } if ($this->errors()) { _style('errors', array('MSG' => $this->get_errors())); } for ($i = 1; $i < 32; $i++) { _style('days', array('DAY' => $i)); } $months = w('Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre'); foreach ($months as $i => $row) { _style('months', array('VALUE' => $i + 1, 'MONTH' => $row)); } for ($i = 2005; $i > 1899; $i--) { _style('years', array('YEAR' => $i)); } // // GeoIP // include XFS . 'core/geoip.php'; $gi = geoip_open(XFS . 'core/GeoIP.dat', GEOIP_STANDARD); $geoip_code = strtolower(geoip_country_code_by_addr($gi, $user->ip)); $sql = 'SELECT * FROM _countries ORDER BY country_name'; $countries = _rowset($sql); $codes = w(); foreach ($countries as $row) { $codes[$row['country_short']] = $row['country_id']; _style('countries', array('VALUE' => $row['country_id'], 'NAME' => $row['country_name'])); } if (!$v['country']) { $v['country'] = isset($codes[$geoip_code]) ? $codes[$geoip_code] : $codes['gt']; } v_style(array('NICKNAME' => $v['nickname'], 'ADDRESS' => $v['address'], 'COUNTRY' => $v['country'], 'BIRTHDAY_YEAR' => $v['birthday']['year'], 'BIRTHDAY_MONTH' => $v['birthday']['month'], 'BIRTHDAY_DAY' => $v['birthday']['day'])); return; }
protected function _faq_cat() { $v = $this->__(w('cat')); if (!$v['cat']) { _fatal(); } $sql = 'SELECT * FROM _help_modules m, _help_faq f, _help_cat c WHERE module_name = ? AND m.module_id = c.help_module AND c.help_id = f.help_id ORDER BY f.faq_order, f.faq_question_es'; $cat = _rowset(sql_filter($sql, $v['cat'])); if (!count($cat)) { _fatal(); } foreach ($cat as $i => $row) { if (!$i) { _style('module'); } _style('module.item', array('URL' => _link('help', $row['faq_id']), 'FAQ' => $row['faq_question_es'])); } $this->_faq_home(); return; }
protected function _create_home() { if (is_post()) { //_pre('a', true); } $v = $this->__(array('grade' => 0, 'subject' => 0, 'exam' => 0, 'year' => 0)); $sql = 'SELECT * FROM _grades g, _sections s WHERE s.section_id = ? AND s.section_grade = g.grade_id'; if (!($grade = _fieldrow(sql_filter($sql, $v['grade'])))) { _fatal(); } $sql = 'SELECT * FROM _subjects WHERE subject_id = ?'; if (!($subject = _fieldrow(sql_filter($sql, $v['subject'])))) { _fatal(); } $sql = 'SELECT * FROM _exams WHERE exam_id = ?'; if (!($exam = _fieldrow(sql_filter($sql, $v['exam'])))) { _fatal(); } if (!$this->check_year($v['year'])) { _fatal(); } $sql = 'SELECT s.student_id, s.student_carne, s.student_firstname, s.student_lastname FROM _students s, _registrations r WHERE r.registration_grade = ? AND r.registration_section = ? AND r.registration_year = ? AND r.registration_student = s.student_id ORDER BY s.student_lastname, s.student_firstname'; if (!($students = _rowset(sql_filter($sql, $grade['grade_id'], $grade['section_id'], $v['year'])))) { _style('students_none'); } $sql = 'SELECT t.student_id, s.score_points FROM _scores s, _students t, _registrations r WHERE s.score_grade = ? AND r.registration_section = ? AND s.score_subject = ? AND s.score_exams = ? AND r.registration_year = ? AND s.score_student = t.student_id AND s.score_student = r.registration_student AND s.score_grade = r.registration_grade ORDER BY t.student_lastname, t.student_firstname'; $scores = _rowset(sql_filter($sql, $grade['grade_id'], $grade['section_id'], $v['subject'], $v['exam'], $v['year']), 'student_id', 'score_points'); foreach ($students as $i => $row) { if (!$i) { _style('students'); } _style('students.row', array('ID' => $row['student_id'], 'CARNE' => $row['student_carne'], 'FIRSTNAME' => $row['student_firstname'], 'LASTNAME' => $row['student_lastname'])); if (!isset($scores[$row['student_id']])) { _style('students.row.input'); } else { _style('students.row.text', array('POINTS' => $scores[$row['student_id']])); } } return; }
public function use_template($template) { global $bio, $core, $database; $template_parts = array_map('trim', explode('/', $template)); $template_file = isset($template_parts[0]) ? $template_parts[0] : 'default'; $template_lang = $bio->v('bio_lang') ? $bio->v('bio_lang') : $core->v('site_lang'); if (!isset($this->template[$template_lang][$template_file])) { // Load template if (!($contents = $core->cache->load('email_' . $template_lang . '_' . $template_file))) { $sql = 'SELECT * FROM _email_template WHERE email_template = ? AND email_lang = ?'; if (!($contents = $core->cache->store(_rowset($sql, $template_file, $template_lang)))) { $this->use_template(); } } $this->template[$template_lang][$template_file] = $contents; } $this->message = $this->template[$template_lang][$template_file]; return true; }
protected function _optimize_home() { $tables = array(); $sql = 'SHOW TABLES'; foreach (_rowset($sql) as $row) { foreach ($row as $v) { $tables[] = $v; } } $sql = 'OPTIMIZE TABLE ' . _implode(', ', $tables); _sql($sql); return $this->e('Done.'); }
protected function _view_home() { global $core, $bio; $v = $this->__(w('alias')); if (!f($v['alias'])) { _fatal(); } $sql = 'SELECT * FROM _contest WHERE contest_alias = ?'; if (!($contest = _fieldrow(sql_filter($sql, $v['alias'])))) { _fatal(); } $contest['expired'] = time() > $contest['contest_end']; $is_contestant = false; if ($bio->v('auth_member')) { $sql = 'SELECT contestant_id FROM _contest_contestant WHERE contestant_contest = ? AND contestant_uid = ?'; if (_fieldrow(sql_filter($sql, $contest['contest_id'], $bio->v('bio_id')))) { $is_contestant = true; } } if ($bio->v('auth_contest_view_stock')) { $sql = 'SELECT * FROM _contest_stock WHERE stock_contest = ? ORDER BY stock_name'; $stock = _rowset(sql_filter($sql, $contest['contest_id'])); $sql = 'SELECT * FROM _contest_contestant c, _bio b WHERE contestant_contest = ? AND contestant_uid = b.bio_id ORDER BY b.bio_alias'; $contestants = _rowset(sql_filter($sql, $contest['contest_id'])); foreach ($contestants as $i => $row) { if (!$i) { _style('contestants'); } _style('contestants.row', array()); } } if ($contest['expired']) { if ($contest['contest_auto_win'] && !$contest['contest_has_win']) { } } else { } $sql = 'SELECT * FROM _contest_stock WHERE stock_contest = ? ORDER BY stock_name'; $stock = _rowset(sql_filter($sql, $contest['contest_id'])); $sql = 'SELECT b.bio_alias, b.bio_name FROM _contest_contestant c, _bio b WHERE c.contestant_contest = ? AND c.contestant_stock > 0 AND c.contestant_uid= b.bio_id ORDER BY c.contestant_stock'; $contestant = _rowset(sql_filter($sql, $content['contest_id']), 'contestant_stock', false, true); foreach ($stock as $i => $row) { if (!$i) { _style('stock'); } _style('stock.row', array('NAME' => $row['stock_name'], 'VALUE' => $row['stock_value'])); if ($v['expired'] && isset($contestant[$row['stock_id']])) { foreach ($contestant[$row['stock_id']] as $j => $row_contestant) { if (!$j) { _style('stock.row.contestant'); } _style('stock.row.contestant.uid', array('NAME' => $row_contestant['bio_name'], 'LINK' => _link_bio($row_contestant['bio_alias']))); } } } v_style(array('CONTEST_SUBJECT' => $contest['contest_subject'], 'CONTEST_CONTENT' => _message($contest['contest_content']))); return; }
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; }
protected function _comments_home() { global $user; $tree = $this->valid_tree(); if (!$tree['tree_allow_comments']) { _fatal(); } $sql = 'SELECT * FROM _comments c, _members m WHERE c.comment_tree = ? AND c.comment_uid = m.user_id ORDER BY 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'], 'USERNAME' => $row['comment_username'], 'EMAIL' => $row['comment_email'], 'WEBSITE' => $row['comment_website'], 'IP' => $row['comment_ip'], 'STATUS' => $row['comment_status'], 'TIME' => _format_date($row['comment_time']), 'MESSAGE' => $row['comment_message'], 'U_VALIDATION' => _link(_rewrite($tree), array('x1' => 'comments', 'x2' => 'validation')))); } if (!count($comments)) { _style('no_comments'); } return $this->_template('tree_comments'); }
protected function _search_home() { if (is_post()) { $v = $this->__(w('carne code firstname lastname')); if (($key = array_least_key($v)) === false) { _fatal(); } $sql = 'SELECT student_carne, student_firstname, student_lastname FROM _students WHERE student_?? ' . "LIKE '??%'\r\n\t\t\t\tORDER BY student_lastname, student_firstname"; if (!($students = _rowset(sql_filter($sql, $key, $v[$key])))) { _style('results_none'); } foreach ($students as $i => $row) { if (!$i) { _style('results'); } _style('results.row', array('STUDENT_FIRSTNAME' => $row['student_firstname'], 'STUDENT_LASTNAME' => $row['student_lastname'], 'U_STUDENT' => _link($this->m(), array('x1' => 'view', 's' => $row['student_carne'])))); } } return; }
protected function _tech_query() { global $user; gfatal(); $v = $this->__(array('tech')); if (!f($v['tech'])) { _fatal(); } $sql = "SELECT user_id, user_firstname, user_lastname\n\t\t\tFROM _members\n\t\t\tWHERE user_firstname LIKE '%??%'"; $members = _rowset(sql_filter($sql, $v['tech'])); $ret = ''; foreach ($members as $row) { $ret .= '<li id="' . $row['user_id'] . '">' . _fullname($row) . '</li>'; } return $this->e('<ul>' . $ret . '</ul>'); }
function _clear_home() { global $user; $v = $this->__(array('id' => 0)); if ($v['id']) { $sql = 'SELECT * FROM _email WHERE email_id = ?'; if (!($email = _fieldrow(sql_filter($sql, $v['id'])))) { $this->e('El registro de email no existe.'); } $sql = 'UPDATE _email SET email_active = ?, email_start = ?, email_end = ?, email_last = ? WHERE email_id = ?'; _sql(sql_filter($sql, 1, 0, 0, 0, $v['id'])); $this->e('El registro de email fue reiniciado.'); } $sql = 'SELECT email_id, email_subject FROM _email ORDER BY email_id'; $emails = _rowset($sql); $response = ''; foreach ($emails as $row) { $response .= '<a href="/faddr/email/x1:clear.id:' . $row['email_id'] . '">' . $row['email_subject'] . '</a><br />'; } $this->e($response); }