Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Modyfikacja kodu - przekierowanie na 404
PiotrN
post
Post #1





Grupa: Zarejestrowani
Postów: 73
Pomógł: 0
Dołączył: 8.05.2010

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


  1. <?php if (!defined('EXEC_TIME')) die('Access restricted');
  2.  
  3. global $PHP_SELF;
  4.  
  5. // Scan external query
  6. // $qhl - query search highlight
  7. list($id, $template, $qhl) = GET('id, template, qhl', 'GPG');
  8.  
  9. // Get alias of ID
  10. $id = cn_id_alias($id);
  11.  
  12. if (!$template) $template = 'Default';
  13. if ($id == 0) die("@SYSLOG: INTERNAL ERROR[2]");
  14.  
  15. $nloc = db_get_nloc($id);
  16. $ent = db_news_load( $nloc );
  17.  
  18. if (!isset($ent[$id]))
  19. {
  20. echo '<div style="text-align: center;">'.i18n('Cannot find an article with id').': <strong>'. intval($id).'</strong></div>';
  21. return FALSE;
  22. }
  23. else
  24. {
  25. $entry = $ent[ $id ];
  26. $text = entry_make($entry, 'full', $template);
  27. $text = cn_snippet_search_hl($text, $qhl);
  28.  
  29. // View statistics
  30. $ent[$id]['vcnt'] = isset($entry['vcnt']) ? $entry['vcnt'] + 1 : 1;
  31. db_save_news($ent, db_get_nloc($id));
  32.  
  33. echo $text;
  34. }
  35.  
  36. return TRUE;


Czy istnieje szansa na przerobienie tego kodu, aby zamiast:
  1. echo '<div style="text-align: center;">'.i18n('Cannot find an article with id').': <strong>'. intval($id).'</strong></div>';
  2. return FALSE;
przekierowywało na 404?

Próbowałem header, ale nie idzie...

Ten post edytował PiotrN 6.09.2019, 11:42:34
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
PiotrN
post
Post #2





Grupa: Zarejestrowani
Postów: 73
Pomógł: 0
Dołączył: 8.05.2010

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


Tak, niestety musiałem kilkukrotnie edytować wklejony tekst w [ PHP ], bo usilnie przekształcało zawarty adres dodając [ URL ].

Oczywiście literówki w kodzie nie popełniłem i problem istniej nadal...
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 7.10.2025 - 14:46