|
|
phpBB2 by Przemo
Support forów phpBB2 modified by Przemo
|
|
[Problem] Fatal error: Maximum execution time of 30 seconds |
Autor |
Wiadomość |
psychol-respect
Posty: 10
|
Wysłany: 19-08-2009, 17:27 [Problem] Fatal error: Maximum execution time of 30 seconds
|
|
|
Kod: | Fatal error: Maximum execution time of 30 seconds exceeded in /home/battlepl/public_html/album_portal.php on line 203 |
Taki błąd pojawia mi się po przeniesieniu bazy danych z cba.pl
hosting z domendą - webd.pl
Wcześniej na "czystej starej" bazie, działał normalnie - był wyświetlany...
Cóż zrobić? |
|
|
|
![](templates/subSilver/images/spacer.gif) |
Gadatliwa Kasia
|
|
|
|
Radek
![zasłużony](templates/subSilver/images/ranks/zasluzeni.gif)
![](images/avatars/6197957854df2037bee536.jpg)
Pomógł: 955 razy Posty: 4614
|
Wysłany: 25-08-2009, 18:40
|
|
|
Ile masz kategorii w albumie? Ten plik album_portal.php jest źle napisany i wykonuje się ponad 30 sek (limit serwera). Należałoby go napisać od nowa / poprawić zamulające fragmenty. Jak ktoś będzie miał czas, to może Ci to zrobi. |
|
|
|
![](templates/subSilver/images/spacer.gif) |
psychol-respect
Posty: 10
|
Wysłany: 27-08-2009, 00:29
|
|
|
Gdyby był źle napisany każdy by miał podobny problem...
Kod: | <?php
/***************************************************************************
* album_portal.php
* ------------------
* begin : Tuesday, February 04, 2003
* copyright : (C) 2003 Smartor
* email : smartor_xp@hotmail.com
* modification : (C) 2003 Przemo http://www.przemo.org
* date modification : ver. 1.12.0 2005/10/9 23:44
*
* $Id: album.php,v 2.0.7 2003/03/15 10:16:30 ngoctu Exp $
*
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
$phpbb_root_path = './';
$album_root_path = $phpbb_root_path . 'album_mod/';
include($album_root_path . 'album_common.'.$phpEx);
$sql = "SELECT c.*, COUNT(p.pic_id) AS count
FROM " . ALBUM_CAT_TABLE . " AS c
LEFT JOIN " . ALBUM_TABLE . " AS p ON (c.cat_id = p.pic_cat_id)
WHERE cat_id <> 0
GROUP BY cat_id
ORDER BY cat_order ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}
$catrows = array();
while( $row = $db->sql_fetchrow($result) )
{
$catrows[] = $row;
}
$allowed_cat = '';
// $catrows now stores all categories which this user can view. Dump them out!
for ($i = 0; $i < count($catrows); $i++)
{
$allowed_cat .= ($allowed_cat == '') ? $catrows[$i]['cat_id'] : ',' . $catrows[$i]['cat_id'];
$l_moderators = '';
$moderators_list = '';
$grouprows= array();
if ( $catrows[$i]['cat_moderator_groups'] != '' )
{
$sql = "SELECT group_id, group_name
FROM " . GROUPS_TABLE . "
WHERE group_single_user <> 1
AND group_type <> ". GROUP_HIDDEN ."
AND group_id IN (". $catrows[$i]['cat_moderator_groups'] .")
ORDER BY group_name ASC";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain usergroups data', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$grouprows[] = $row;
}
}
if ( count($grouprows) > 0 )
{
$l_moderators = $lang['Moderators'];
for ($j = 0; $j < count($grouprows); $j++)
{
$group_link = '<a href="'. append_sid("groupcp.$phpEx?". POST_GROUPS_URL .'='. $grouprows[$j]['group_id']) .'">'. $grouprows[$j]['group_name'] .'</a>';
$moderators_list .= ($moderators_list == '') ? $group_link : ', ' . $group_link;
}
}
// Get Last Pic of this Category
if ( $catrows[$i]['count'] == 0 )
{
$last_pic_info = $lang['No_Pics'];
$u_last_pic = '';
$last_pic_title = '';
}
else
{
// Check Pic Approval
if ( ($catrows[$i]['cat_approval'] == ALBUM_ADMIN) or ($catrows[$i]['cat_approval'] == ALBUM_MOD) )
{
$pic_approval_sql = 'AND p.pic_approval = 1';
}
else
{
$pic_approval_sql = '';
}
// OK, we may do a query now...
$sql = "SELECT p.pic_id, p.pic_title, p.pic_user_id, p.pic_username, p.pic_time, p.pic_cat_id, u.user_id, u.username
FROM " . ALBUM_TABLE . " AS p
LEFT JOIN " . USERS_TABLE . " AS u ON (p.pic_user_id = u.user_id)
WHERE p.pic_cat_id = '". $catrows[$i]['cat_id'] ."' $pic_approval_sql
ORDER BY p.pic_time DESC
LIMIT 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not get last pic information', '', __LINE__, __FILE__, $sql);
}
$lastrow = $db->sql_fetchrow($result);
$last_pic_info = create_date($board_config['default_dateformat'], $lastrow['pic_time'], $board_config['board_timezone']);
$last_pic_info .= '<br />';
// Write username of last poster
if ( ($lastrow['user_id'] == ALBUM_GUEST) or ($lastrow['username'] == '') )
{
$last_pic_info .= ($lastrow['pic_username'] == '') ? $lang['Guest'] : $lastrow['pic_username'];
}
else
{
$last_pic_info .= $lang['Poster'] .': <a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $lastrow['user_id']) .'">'. $lastrow['username'] .'</a>';
}
// Write the last pic's title. Truncate it if it's too long
if ( !isset($album_config['last_pic_title_length']) )
{
$album_config['last_pic_title_length'] = 25;
}
$lastrow['pic_title'] = $lastrow['pic_title'];
if (strlen($lastrow['pic_title']) > $album_config['last_pic_title_length'])
{
$lastrow['pic_title'] = substr($lastrow['pic_title'], 0, $album_config['last_pic_title_length']) . '...';
}
$last_pic_info .= '<br />'. $lang['Pic_Title'] .': <a href="';
$last_pic_info .= ($album_config['fullpic_popup']) ? append_sid("album_pic.$phpEx?pic_id=". $lastrow['pic_id']) .'" target="_blank">' : append_sid("album_page.$phpEx?pic_id=". $lastrow['pic_id']) .'">' ;
$last_pic_info .= $lastrow['pic_title'] .'</a>';
}
}
if ( $portal_config['recent_pics'] < 2 )
{
$lang_last_pics = $lang['Last_Pic'];
}
else
{
$lang_last_pics = $lang['Recent_Public_Pics'];
}
if ( $allowed_cat != '' )
{
$sql = "SELECT p.pic_id, pic_filename, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_user_ip, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_view_count, u.user_id, u.username, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments
FROM " . ALBUM_TABLE . " AS p
LEFT JOIN " . USERS_TABLE . " AS u ON (p.pic_user_id = u.user_id)
LEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON (p.pic_cat_id = ct.cat_id)
LEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON (p.pic_id = r.rate_pic_id)
LEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON (p.pic_id = c.comment_pic_id)
WHERE p.pic_cat_id IN ($allowed_cat) AND p.pic_approval = 1 OR ct.cat_approval = 0
GROUP BY p.pic_id
ORDER BY pic_time DESC
LIMIT ". $portal_config['recent_pics'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query recent pics information', '', __LINE__, __FILE__, $sql);
}
$recentrow = array();
while( $row = $db->sql_fetchrow($result) )
{
$recentrow[] = $row;
}
if ( count($recentrow) > 0 )
{
$template->assign_vars(array(
'L_POSTER' => $lang['Poster'],
'L_RATING' => $lang['Rating'],
'L_COMMENTS' => $lang['Comments'],
'ALBUM_ALIGN' => $portal_config['album_pos'],
'L_LAST_PIC' => $lang_last_pics)
);
for ($i = 0; $i < count($recentrow); $i += $album_config['cols_per_page'])
{
for ($j = $i; $j < ($i + $album_config['cols_per_page']); $j++)
{
if ( $j >= count($recentrow) )
{
break;
}
if ( !$recentrow[$j]['rating'] )
{
$recentrow[$j]['rating'] = $lang['Not_rated'];
}
else
{
$recentrow[$j]['rating'] = round($recentrow[$j]['rating'], 2);
}
$pic_size = @getimagesize(ALBUM_UPLOAD_PATH . $recentrow[$j]['pic_filename']);
$pic_width = ($pic_size[0] + 20);
$pic_height = ($pic_size[1] + 25);
if ( $album_config['fullpic_popup'] )
{
$u_pic = append_sid("album_pic.$phpEx?pic_id=". $recentrow[$j]['pic_id']);
if ( $pic_size )
{
$u_pic = "javascript:displayWindow('$u_pic',$pic_width,$pic_height)";
}
else if ( $album_config['fullpic_popup'] )
{
$target_blank = ' target="_blank"';
}
else
{
$target_blank = '';
}
}
else
{
$u_pic = append_sid("album_page.$phpEx?pic_id=". $recentrow[$j]['pic_id']);
}
if ( ($recentrow[$j]['user_id'] == ALBUM_GUEST) or ($recentrow[$j]['username'] == '') )
{
$recent_poster = ($recentrow[$j]['pic_username'] == '') ? $lang['Guest'] : $recentrow[$j]['pic_username'];
}
else
{
$recent_poster = '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $recentrow[$j]['user_id']) .'">'. $recentrow[$j]['username'] .'</a>';
}
$template->assign_block_vars('album_pics', array(
'PIC_TITLE' => $recentrow[$j]['pic_title'],
'PIC_SRC' => $u_pic,
'TARGET_B' => $target_blank,
'PIC_DESC' => $recentrow[$j]['pic_desc'],
'PIC_THUMB' => append_sid("album_thumbnail.$phpEx?pic_id=" . $recentrow[$j]['pic_id']),
'RECENT_POSTER' => $recent_poster,
'PIC_DATE' => create_date($board_config['default_dateformat'], $recentrow[$j]['pic_time'], $board_config['board_timezone']),
'RATE_URL' => append_sid("album_rate.$phpEx?pic_id=". $recentrow[$j]['pic_id']),
'RATING' => $recentrow[$j]['rating'],
'COMMENT_URL' => append_sid("album_comment.$phpEx?pic_id=". $recentrow[$j]['pic_id']),
'COMMENTS' => $recentrow[$j]['comments'])
);
}
}
$template->set_filenames(array(
'album_menu' => 'portal_modules/album_menu.tpl')
);
$template->assign_var_from_handle($module_names['album_menu'], 'album_menu');
}
}
?> |
tak wygląda ten album_portal.php - oryginalny z paczki z tej strony (taki mam na BP)
//EDIT:
Wywaliłem z portalu ALBUM - by nie pokazywało go na nim i portal znów działa |
|
|
|
![](templates/subSilver/images/spacer.gif) |
Radek
![zasłużony](templates/subSilver/images/ranks/zasluzeni.gif)
![](images/avatars/6197957854df2037bee536.jpg)
Pomógł: 955 razy Posty: 4614
|
Wysłany: 27-08-2009, 11:43
|
|
|
psychol-respect napisał/a: | Gdyby był źle napisany każdy by miał podobny problem... |
Nie każdy, bo to zależy też od konfiguracji serwera. Zapytania w pętli zamulają i tyle, ale skoro wiesz lepiej, to radź sobie sam. |
|
|
|
![](templates/subSilver/images/spacer.gif) |
psychol-respect
Posty: 10
|
Wysłany: 27-08-2009, 14:23
|
|
|
RuseK napisał/a: | ale skoro wiesz lepiej, to radź sobie sam. |
nie wiem lepiej, to czysta intuicja, jeżeli Cię to uraziło to sory.
Da radę jakoś ten "album" w bazie wyzerować ? |
|
|
|
![](templates/subSilver/images/spacer.gif) |
Radek
![zasłużony](templates/subSilver/images/ranks/zasluzeni.gif)
![](images/avatars/6197957854df2037bee536.jpg)
Pomógł: 955 razy Posty: 4614
|
Wysłany: 27-08-2009, 15:17
|
|
|
A korzystasz z niego? Jeżeli tak i jest Ci potrzebny podgląd fotek w portalu to nic nie zrobisz, będzie zamulać, trzeba poprawić album_portal.php. Jak nie chcesz go używać, to po prostu wyłącz w konfiguracji portalu Ostatnie zdjęcia z albumu albo usuń z albumu wszystkie kategorie i fotki ( ew zostaw jedną kategorię i tam pakuj fotki, może będzie działać trochę szybciej ) |
|
|
|
![](templates/subSilver/images/spacer.gif) |
|
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum
|
Dodaj temat do Ulubionych Wersja do druku
|
Kopiowanie wszelkich treści zawartych na forum, modyfikacji oraz instrukcji bez zgody administracji i autorów tematów/postów zabronione!
Powered by phpBB modified by Przemo © 2003 phpBB
| Strona wygenerowana w 0,09 sekundy. Zapytań do SQL: 11 | |
![](images/spacer.gif) |
|