Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z obciążeniem bazy SQL-poddało się wielu
kontrowersje
post 27.10.2009, 16:21:07
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 27.10.2009

Ostrzeżenie: (0%)
-----


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:

  1. <?php
  2.  
  3. $right=ereg_replace('{a', '
  4. $right=ereg_replace("{/a}", '', $right);
  5. $right=ereg_replace('{img ', '
  6. $right=ereg_replace('"}', '">', $right);
  7.  
  8. $right=ereg_replace('
  9. ', '
  10. ', $right);
  11.  
  12. $right=ereg_replace("December", "Grudzień", $right);
  13. $right=ereg_replace("November", "Listopad", $right);
  14. $right=ereg_replace("September", "Wrzesień", $right);
  15. $right=ereg_replace("October", "Październik", $right);
  16. $right=ereg_replace("January", "Styczeń", $right);
  17. $right=ereg_replace("February", "Luty", $right);
  18. $right=ereg_replace("March", "Marzec", $right);
  19. $right=ereg_replace("April", "Kwiecień", $right);
  20.  
  21. $right=ereg_replace("May", "Maj", $right);
  22. $right=ereg_replace("Juni", "Czerwiec", $right);
  23. $right=ereg_replace("July", "Lipiec", $right);
  24. $right=ereg_replace("August", "Sierpień", $right);
  25.  
  26. $right=ereg_replace(' ndz.
  27.  
  28. ', ' ndz.
  29.  
  30. ',$right);
  31.  
  32. $right=ereg_replace('
  33. ', '
  34. ',$right);
  35.  
  36. $right=ereg_replace('
  37. ', '
  38. ',$right);
  39.  
  40. $right=ereg_replace('Ostatnio dodane odpowiedzi', '',$right);
  41. $right=ereg_replace('zaktualizowany', '',$right);
  42. $right=ereg_replace('Szybka odpowiedź', '',$right);
  43.  
  44. if (!$user->roles[2]) $right=ereg_replace('Mój blog
  45. # Pisz bloga
  46.  
  47. ', '',$right);
  48.  
  49. print $right;
  50.  
  51. $profile = profile_load_profile($user);
  52.  
  53. $ostatnie_odpowiedzi = $user->profile_ostatnie_odpowiedzi;
  54. if($ostatnie_odpowiedzi < 5) $ostatnie_odpowiedzi = 5;
  55. $ignorowani = '';
  56. $ignorowani .= " AND (UPPER(comments.name) != UPPER('Lustro')) ";
  57. $ignorowani .= " AND (UPPER(comments.name) != UPPER('MaciekS')) ";
  58. $ignorowani .= " AND (UPPER(comments.name) != UPPER('Leyte')) ";
  59. //$ignorowani .= " AND (UPPER(comments.name) != UPPER('zlotousty_klamca')) ";
  60.  
  61. $query = "SELECT node.nid AS nid,
  62. node.uid as uid
  63. FROM {node} node
  64. LEFT JOIN {term_node} term_node_174 ON node.vid = term_node_174.vid AND term_node_174.tid = 174
  65. WHERE (term_node_174.tid = 174) and node.nid >50";
  66.  
  67. $queryResult = db_query($query);
  68.  
  69. while ($nodescount = db_fetch_object($queryResult)) {
  70.  
  71. $comments_priv .= " and comments.nid<>".$nodescount->nid." ";
  72.  
  73. }
  74.  
  75. $query="SELECT comments.cid AS cid,
  76. comments.subject AS comments_subject,
  77. comments.nid AS comments_nid,
  78. comments.pid As comments_pid,
  79. comments.timestamp AS comments_timestamp,
  80. comments.name AS comments_name,
  81. comments.uid AS comments_uid,
  82. comments.homepage AS comments_homepage,
  83. comments.comment AS comments_comment,
  84. comments.format AS comments_format,
  85. history_user.timestamp AS history_user_timestamp,
  86. history_user.nid AS history_user_nid,
  87. node_comments.created AS node_comments_created,
  88. node_comments.changed AS node_comments_changed,
  89. node_comments__node_comment_statistics.last_comment_timestamp AS node_comments__node_comment_statistics_last_comment_timestamp,
  90. node_comments.nid AS node_comments_nid
  91. FROM root_comments comments
  92. LEFT JOIN root_node node_comments ON comments.nid = node_comments.nid
  93. LEFT JOIN root_history history_user ON node_comments.nid = history_user.nid AND history_user.uid = ".$user->uid."
  94. 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
  95. WHERE (node_comments.status <> 0 OR node_comments.uid = ".$user->uid.")".$ignorowani.$comments_priv."
  96. ORDER BY comments_timestamp DESC limit ".$ostatnie_odpowiedzi."";
  97.  
  98. $queryResult = db_query($query);
  99.  
  100. ?>


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
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 13:12