Witam jestem kompletnym ignorantem w PHP, usiłuję jedynie znaleźć kogoś, kto jest w stanie poprawić poniższy kod, który obciąża bazę SQL. Próbowało wielu PHP-owców, ale nikt nie był w stanie znaleźć przyczyny "mulenia" serwera. Wiem, że jest tu kilka kosmetycznych błędów składni, ale problem tkwi w zapytaniu da bazy, to potwierdzili wszyscy analizujący kod. Strona chodzi pod adresem kontrowersje.net, na cms Drupal, kod który wywala serwer jest następujący:
<?php
$right=ereg_replace("{/a}", '', $right);
$right=ereg_replace('{img ', '
', '
', $right);
', ' ndz.
',$right);
', '
',$right);
', '
',$right);
$right=ereg_replace('Ostatnio dodane odpowiedzi', '',$right);
# Pisz bloga
', '',$right);
$profile = profile_load_profile($user);
$ostatnie_odpowiedzi = $user->profile_ostatnie_odpowiedzi;
if($ostatnie_odpowiedzi < 5) $ostatnie_odpowiedzi = 5;
$ignorowani = '';
$ignorowani .= " AND (UPPER(comments.name) != UPPER('Lustro')) ";
$ignorowani .= " AND (UPPER(comments.name) != UPPER('MaciekS')) ";
$ignorowani .= " AND (UPPER(comments.name) != UPPER('Leyte')) ";
//$ignorowani .= " AND (UPPER(comments.name) != UPPER('zlotousty_klamca')) ";
$query = "SELECT node.nid AS nid,
node.uid as uid
FROM {node} node
LEFT JOIN {term_node} term_node_174 ON node.vid = term_node_174.vid AND term_node_174.tid = 174
WHERE (term_node_174.tid = 174) and node.nid >50";
$queryResult = db_query($query);
while ($nodescount = db_fetch_object($queryResult)) {
$comments_priv .= " and comments.nid<>".$nodescount->nid." ";
}
$query="SELECT comments.cid AS cid,
comments.subject AS comments_subject,
comments.nid AS comments_nid,
comments.pid As comments_pid,
comments.timestamp AS comments_timestamp,
comments.name AS comments_name,
comments.uid AS comments_uid,
comments.homepage AS comments_homepage,
comments.comment AS comments_comment,
comments.format AS comments_format,
history_user.timestamp AS history_user_timestamp,
history_user.nid AS history_user_nid,
node_comments.created AS node_comments_created,
node_comments.changed AS node_comments_changed,
node_comments__node_comment_statistics.last_comment_timestamp AS node_comments__node_comment_statistics_last_comment_timestamp,
node_comments.nid AS node_comments_nid
FROM root_comments comments
LEFT JOIN root_node node_comments ON comments.nid = node_comments.nid
LEFT JOIN root_history history_user ON node_comments.nid = history_user.nid AND history_user.uid = ".$user->uid."
LEFT JOIN root_node_comment_statistics node_comments__node_comment_statistics ON node_comments.nid = node_comments__node_comment_statistics.nid and last_comment_uid<>519
WHERE (node_comments.status <> 0 OR node_comments.uid = ".$user->uid.")".$ignorowani.$comments_priv."
ORDER BY comments_timestamp DESC limit ".$ostatnie_odpowiedzi."";
$queryResult = db_query($query);
?>
Będę wdzięczny za wszelkie sugestie i podpowiedzi, jestem również skłonny nawiązać współpracę na zasadzie zleceń z kimś kto da sobie radę z PHP i Drupalem
kontrowersje@kontrowersje.net
Ten post edytował kontrowersje 27.10.2009, 18:34:13