$tpl_profile = str_replace("%HOME%", $HOME_TEXT, $tpl_profile); $tpl_profile = str_replace("%HOME_LINK%", $linkurl, $tpl_profile); $tpl_friends = addslashes($tpl_friends); $tpl_friends = str_replace("%HOME%", $HOME_TEXT, $tpl_friends); $tpl_friends = str_replace("%HOME_LINK%", $linkurl, $tpl_friends); $db = new sqldb2($DB_CONFIG_v2); // get users $name_id = array(); $all_users = array(); $t = $db->query('SELECT * FROM nlb_users;'); while ($row = mysql_fetch_assoc($t)) { $all_users[] = $row; $name_id[$row['username']] = $row['id']; } // get blogs $all_blogs = $db->getAllArray('SELECT * FROM nlb_blogs;'); // get comments $all_com = $db->getAllArray('SELECT * FROM nlb_comments;'); $db->clear(); $db->setConfig($DB_CONFIG_v3); $db->connect(); $now = time(); $past = 458895600; // // INSERT USERS // foreach ($all_users as $u) { if (isset($_GET['old']) && $_GET['old'] == 'true') { $u['bio'] = addslashes($u['bio']); $u['custom_title'] = addslashes($u['custom_title']); $u['username'] = addslashes($u['username']);
* S H O W N E W S * ======================================= */ $ets_outter->main_title = $config->get('site_name') . ': ' . $l['title-news']; $ets_outter->page_title = $l['title-news']; $page = 0; if (isset($_PATH['page'])) { $page = $_PATH['page']; } $q = '# GET NEWS POSTS SELECT t1.blog_id, t1.author_id, t1.date, t1.subject, t1.body, t1.access, t1.custom AS custom_text, t1.comments, t1.html, t1.smiles, t1.bb, t2.username AS author, t2.custom AS custom_title FROM ' . db_blogs . ' AS t1, ' . db_users . ' AS t2 WHERE t1.author_id = t2.user_id AND t1.access = ' . access_news . ' ORDER BY t1.date DESC LIMIT ' . $page . ' , ' . $config->get('news_per_page') . ' ;'; $newsitems = $db->getAllArray($q); $b->setDate($config->get('news_date_format')); foreach ($newsitems as $news) { $b->setData($news); $ets->news[] = $b->format(false, $user, $l['edit']); } $USESKIN = skin_news; break; case 'comment': /** * ======================================= * N E W S C O M M E N T S * ======================================= */ $USESKIN = skin_news; $ets_outter->main_title = $config->get('site_name') . ': ' . $l['title-news'];
$perpage = $u->get('perpage'); $page_start = $page * $perpage; // get avatar for this user $av = $db->getArray('SELECT file, isCustom FROM ' . db_avatars . ' WHERE owner_id=' . $USERID . ' AND type=1;'); if (!empty($av)) { if ($av['isCustom'] == 1) { $file = 'avatars/'; } else { $file = 'avatars/default/'; } $file .= $av['file']; $ets->avatar_url = script_path . $file; $ets->avatar = '<img src="' . script_path . $file . '" />'; } // get list of friends $list = $db->getAllArray('SELECT friend_id FROM ' . db_friends . ' WHERE owner_id = ' . $USERID . ';'); if ($db->getRowCount() == 0) { // This user has no friends. $ets->blog[0]->body = $l['no-friends']; $ets->blog[0]->comments = false; $ets->blog[0]->author = $u->get('username'); $ets->blog[0]->date = date('M jS, Y g:i a'); } else { // this user does have friends. // build it into an IN() paramater $in = ''; foreach ($list as $row) { $in .= $row['friend_id'] . ', '; } $in = substr($in, 0, -2); // get avatars of friends.
$allowed_sort = array('username', 'blog_count', 'registered'); if (isset($_PATH['sort']) && in_array($_PATH['sort'], $allowed_sort)) { $sort = $_PATH['sort']; } $way = 'asc'; if (isset($_PATH['way']) && ($_PATH['way'] == 'asc' || $_PATH['way'] == 'desc')) { $way = $_PATH['way']; } $page = 0; if (isset($_PATH['page'])) { $page = $_PATH['page']; } $start = $page * $perpage; // get and process a page of members $i = 0; $all = $db->getAllArray("SELECT user_id, username, blog_count, registered FROM " . db_users . " WHERE valid = 1 ORDER BY {$sort} {$way} LIMIT {$start}, {$perpage} ;"); foreach ($all as $row) { stripslashes_array($row); $ets->members[$i]->username = $row['username']; $ets->members[$i]->blog_count = $row['blog_count']; $ets->members[$i]->url_blogs = build_link('blog.php', array('user' => $row['user_id'])); $ets->members[$i]->url_profile = build_link('profile.php', array('user' => $row['user_id'])); $ets->members[$i]->registered = date($date_format, $row['registered']); $i++; } // setup next/prev links $total = $db->getArray("SELECT count(*) as c FROM " . db_users . ";"); $total = $total['c']; if ($page > 0) { $ets->url_page_prev = build_link('members.php', array('page' => $page - 1, 'sort' => $sort, 'way' => $way)); }
$mask = 'results'; $page = $_GET['page'] + 0; // easy cast to int $start = $page * 10; $end = $start + 10; $url = build_link('search.php?page=%d'); if ($page > 0) { $ets->url_prev = sprintf($url, $page - 1); } if ($end < $_SESSION['results']) { $ets->url_next = sprintf($url, $page + 1); } $ets->matches = $_SESSION['results']; $q = $_SESSION['query']; $q .= " \nORDER BY b.date DESC \nLIMIT {$start}, {$end};"; $page = $db->getAllArray($q); $i = 0; foreach ($page as $b) { stripslashes_array($b); $ets->entries[$i]->author = $b['username']; $ets->entries[$i]->url = build_link('blog.php', array('id' => $b['blog_id'])); $ets->entries[$i]->subject = $b['subject']; $ets->entries[$i]->comments = $b['comments']; if ($b['html'] == 0) { $b['body'] = htmlspecialchars($b['body']); } if ($b['bb'] == 1) { $b['body'] = insertBBCode($b['body']); } $b['body'] = nl2br($b['body']); $ets->entries[$i]->body = truncate($b['body'], 800);
// default is public blogs only. if ($user->isLogedIn) { // if we are the author, we can see all if ($user->id == $u->id) { $access_in = access_public . ', ' . access_private . ', ' . access_friendsonly; } // are we a friend? if ($u->areFriends($user->id)) { $access_in = access_public . ', ' . access_friendsonly; } } // get the blogs $all = $db->getAllArray('# Get page of blogs SELECT b.blog_id, b.author_id, b.date, b.subject, b.body, b.access, b.mood, b.custom AS custom_text, b.comments, b.html, b.smiles, b.bb, u.username AS author, u.custom AS custom_title, u.date_format FROM ' . db_blogs . ' AS b, ' . db_users . ' AS u WHERE u.user_id = ' . $USERID . ' AND b.author_id = u.user_id AND b.access IN(' . $access_in . ') ORDER BY b.date DESC LIMIT ' . $limit . ';'); // timezone settings if ($user->isLogedIn) { $blog->setDateOffset($config->get('server_timezone'), $user->get('timezone')); } // check for avatars $avatar = $db->getArray('SELECT file, isCustom FROM ' . db_avatars . ' WHERE owner_id=' . $USERID . ' AND type=1;'); if (!empty($avatar)) { if ($avatar['isCustom'] == 1) { $file = 'avatars/'; } else { $file = 'avatars/default/'; }