SimplePortal

Support => Turkish (Türkçe) => International Support => Ki?iselle?tirme => Topic started by: Paragaya on February 22, 2009, 04:55:15 AM

Title: [Blok]Rastgele Konu
Post by: Paragaya on February 22, 2009, 04:55:15 AM

A?a??daki kodu bir php blok a kaydederseniz rastgele bir konu görüntüler :)

Code: [Select]
global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context;
global $func;
$length= 300;

loadLanguage('Stats');

if ($length === null)
$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
else
$length = (int) $length;

// Make sure guests can see this board.
$request = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE FIND_IN_SET(-1, memberGroups)
        ORDER BY rand()
LIMIT 1", __FILE__, __LINE__);

list ($board) = mysql_fetch_row($request);
mysql_free_result($request);

// Load the message icons - the usual suspects.
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find the post ids.
$request = db_query("
SELECT ID_FIRST_MSG
FROM {$db_prefix}topics
WHERE ID_BOARD = $board
ORDER BY rand()
LIMIT 1", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
$posts[] = $row['ID_FIRST_MSG'];
mysql_free_result($request);

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
LIMIT 1", __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
{
// If we want to limit the length of the post.
if (!empty($length) && $func['strlen']($row['body']) > $length)
{
$row['body'] = $func['substr']($row['body'], 0, $length);
// The first space or line break. (<br />, etc.)
        $cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<'));

if ($cutoff !== false)
$row['body'] = $func['substr']($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

// Check that this message icon is there...
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

censorText($row['subject']);
censorText($row['body']);

$return[] = array(
'id' => $row['ID_TOPIC'],
'message_id' => $row['ID_MSG'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',
'replies' => $row['numReplies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
),
'locked' => !empty($row['locked']),
);
}
mysql_free_result($request);

foreach ($return as $news)
{
echo '
<div>
<a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
<div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>

<div class="post" style="padding: 2ex 0;">', $news['body'], '</div>

', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>';
}
Title: Re: [Blok]Rastgele Konu
Post by: MUSTAFAINE on April 27, 2009, 11:05:07 AM
tesekkurler hos paylasim
Title: Re: [Blok]Rastgele Konu
Post by: Paragaya on April 29, 2009, 02:54:10 AM
önemli deil.
Title: Re: [Blok]Rastgele Konu
Post by: MDFC on June 29, 2009, 10:48:19 AM
Fatal error: Call to undefined function db_query() in /home/meshlcom/public_html/sozluk/Sources/SPortal2.php(3218) : eval()'d code on line 13

hatası veriyo :(
Title: Re: [Blok]Rastgele Konu
Post by: kral on March 26, 2010, 11:12:57 AM
yalnız bu konuda ilgili konularda resim var ise resim olğu gibi çıkıyor. Yani resim büyük ise sağ veya sol bloklarda çok büyük çıkıyor.
Title: Re: [Blok]Rastgele Konu
Post by: grafitus on March 26, 2010, 12:17:28 PM
yalnız bu konuda ilgili konularda resim var ise resim olğu gibi çıkıyor. Yani resim büyük ise sağ veya sol bloklarda çok büyük çıkıyor.
Kodun $length= 300; ifadesinideki 300 karakter sınırını düşürün.
Title: Re: [Blok]Rastgele Konu
Post by: kral on March 26, 2010, 12:45:08 PM
olmuyor. 487 x 700 piksel olan bir resmi mesela sağ blokta gösteriyor ama bu resmi sağ blok küçültmesi gerekiyor ki oraya sığsın. karakter sayısını küçültmek resimleri küçültmek anlamına gelmiyor malesef.
Title: Re: [Blok]Rastgele Konu
Post by: grafitus on March 26, 2010, 03:04:36 PM
Gelmiyor zaten, resimler yok olmuş oluyordu. Neyse, aşağıdaki şlemi yapın (Deneme fırsatım yoktu).
Kodda;
Code: (Bulun) [Select]
mysql_free_result($request);
Code: (Değiştirin) [Select]
mysql_free_result($request);
$return['body'] = preg_replace('~<img\s+src="([^"]+)"([^/>]+)/>~i', '<img src="$1"$2width="75px" />', $return['body']);
Title: Re: [Blok]Rastgele Konu
Post by: kral on March 26, 2010, 04:03:39 PM
değişiklik yok aynı. Ayrıca verdiğin koddan 2 tane var ikisine de uyguladım olmadı. konulardaki resimler olduğu gibi çıkıyor.
Title: Re: [Blok]Rastgele Konu
Post by: grafitus on April 09, 2010, 11:43:49 AM
Kod SMF 1.1.x serisi için...
Title: Re: [Blok]Rastgele Konu
Post by: mutluokul on October 17, 2011, 03:08:09 AM
smf 2.0.1 için olanı çıkacak mı? kullanan arkadaş varsa paylaşabilr mi? teşekkürler.
SimplePortal 2.3.8 © 2008-2024, SimplePortal