Codigos Fan Pages
http://pastebin.com/PGFh3Qt6
Buscador
Código PHP:
class search{
function index() {
c('
<form action="'.url('search/listing').'" method="post">
<p>
<label>title</label> <input type="text" name="title" />
</p>
<p>
<input type="submit" class="button" value="'.t('Submit').'" />
</p>
</form>
');
}
function listing() {
global $offset, $num_per_page, $page;
$title = trim($_POST['title']);
$display_title = stripslashes(trim($_POST['title']));
c('Searching <strong>'.h($title).'</strong><br />');
if (strlen($title) < 3) {
sys_back(t('Keyword is too short'));
}
else {
$hash = substr(md5($title),0,12);
if ($c = get_cache($hash)) {
header("location:".url('search/result/'.$hash));
exit;
}
else {
$c = '<h1>'.h($display_title).'</h1>';
$res = sql_query("select * from ".tb()."accounts where username like '%{$title}%' or fullname like '%{$title}%' order by lastlogin DESC limit 10");
while ($user = sql_fetch_array($res)) {
$users .= '<li>'.url('u/'.$user['username'],$user['username']).'<br />'.avatar($user).'<br />'.h($user['fullname']).'</li>';
}
if (strlen($users)) {
$c .= '<h2>'.t('Members').'</h2>';
$c .= '<ul class="small_avatars">'.$users.'</ul>';
}
$c .= '<h2>'.t('Stories').'</h2>
<p>Searching for <strong>"'.h($title).'"</strong></p>';
$res = sql_query("select s.*,u.username from `".tb()."stories` as s left join ".tb()."accounts as u on u.id=s.uid where s.title LIKE '%$title%' ORDER BY s.id DESC LIMIT 20");
if (!sql_counts($res)) {
$c .= '<p>no story matched</p>';
}
else {
$c .= 'Stories:<br /><ul class="post">';
while($story = sql_fetch_array($res)) {
$c .= '<li>
['.url($story['app'],app_name($story['app'])).']
<a href="'.url($story['app'].'/viewstory/'.$story['id']).'">'.str_replace($title,'<strong>'.h($title).'</strong>',htmlspecialchars($story['title'])).'</a><br />'.get_date($story['created']).', by '.url('u/'.$story['username'],$story['username']).'
</li>';
}
$c .= '</ul>';
}
set_cache($hash, $c, 48);
header("location:".url('search/result/'.$hash));
exit;
$c .= '<h2>'.t('Forums').'</h2>
<p>Searching for <strong>"'.h($title).'"</strong></p>';
$res = sql_query("select * from `".tb()."forum_threads` where topic LIKE '%$title%' ORDER BY lastpostcreated DESC LIMIT 20");
if (!sql_counts($res)) {
$c .= '<p>no threads matched</p>';
}
else {
$c .= 'Threads:<br /><ul class="post">';
while($thread = sql_fetch_array($res)) {
$res2 = sql_query("select * from `".tb()."forums` where id=".$thread['fid']."");
$forum = sql_fetch_array($res2);
$c .= '<li>
['.url('forums/listthreads/'.$forum['id'].'',t($forum['name'])).']
<a href="'.url('forums/viewthread/'.$thread['id'].'').'">'.str_replace($title,'<strong>'.h($title).'</strong>',htmlspecialchars($thread['topic'])).'</a><br />'.get_date($thread['created']).', by '.url('u/'.$thread['username'],$thread['username']).'
</li>';
}
$c .= '</ul>';
}
}
}
}
function result($hash) {
set_title('Search result');
c(get_cache($hash).get_gvar('ad_block_search'));
}
}